/**
* @var bool Whether or not a text for stdin has been provided
*/
- private $mockSetUp = False;
+ private $mockSetUp = false;
/**
* @var Array Invocation counters for the mocked aspects
private $mockInvocations = array( 'getStdin' => 0 );
-
/**
* Data for the fake stdin
*
* @param $stdin String The string to be used instead of stdin
*/
- function mockStdin( $stdin )
- {
+ function mockStdin( $stdin ) {
$this->mockStdinText = $stdin;
- $this->mockSetUp = True;
+ $this->mockSetUp = true;
}
/**
* @return Array An array, whose keys are function names. The corresponding values
* denote the number of times the function has been invoked.
*/
- function mockGetInvocations()
- {
+ function mockGetInvocations() {
return $this->mockInvocations;
}
// -----------------------------------------------------------------
// Mocked functions from FetchText follow.
- function getStdin( $len = null )
- {
+ function getStdin( $len = null ) {
$this->mockInvocations['getStdin']++;
if ( $len !== null ) {
throw new PHPUnit_Framework_ExpectationFailedException(
"Tried to get stdin with non null parameter" );
}
- if ( ! $this->mockSetUp ) {
+ if ( !$this->mockSetUp ) {
throw new PHPUnit_Framework_ExpectationFailedException(
"Tried to get stdin before setting up rerouting" );
}
$this->tablesUsed[] = 'revision';
$this->tablesUsed[] = 'text';
+ $wikitextNamespace = $this->getDefaultWikitextNS();
+
try {
- $title = Title::newFromText( 'FetchTextTestPage1' );
+ $title = Title::newFromText( 'FetchTextTestPage1', $wikitextNamespace );
$page = WikiPage::factory( $title );
$this->textId1 = $this->addRevision( $page, "FetchTextTestPage1Text1", "FetchTextTestPage1Summary1" );
- $title = Title::newFromText( 'FetchTextTestPage2' );
+ $title = Title::newFromText( 'FetchTextTestPage2', $wikitextNamespace );
$page = WikiPage::factory( $title );
$this->textId2 = $this->addRevision( $page, "FetchTextTestPage2Text1", "FetchTextTestPage2Summary1" );
$this->textId3 = $this->addRevision( $page, "FetchTextTestPage2Text2", "FetchTextTestPage2Summary2" );
}
-
// Instead of the following functions, a data provider would be great.
// However, as data providers are evaluated /before/ addDBData, a data
// provider would not know the required ids.
function testExistingSeveral() {
$this->assertFilter( "$this->textId1\n$this->textId5\n"
- . "$this->textId3\n$this->textId3",
+ . "$this->textId3\n$this->textId3",
implode( "", array(
- $this->textId1 . "\n23\nFetchTextTestPage1Text1",
- $this->textId5 . "\n44\nFetchTextTestPage2Text4 "
+ $this->textId1 . "\n23\nFetchTextTestPage1Text1",
+ $this->textId5 . "\n44\nFetchTextTestPage2Text4 "
. "some additional Text",
- $this->textId3 . "\n23\nFetchTextTestPage2Text2",
- $this->textId3 . "\n23\nFetchTextTestPage2Text2"
- ) ) );
+ $this->textId3 . "\n23\nFetchTextTestPage2Text2",
+ $this->textId3 . "\n23\nFetchTextTestPage2Text2"
+ ) ) );
}
function testEmpty() {
function testMix() {
$this->assertFilter( "ab\n" . $this->textId4 . ".5cd\n\nefg\n" . $this->textId2
- . "\n" . $this->textId3,
+ . "\n" . $this->textId3,
implode( "", array(
- "0\n-1\n",
- $this->textId4 . "\n23\nFetchTextTestPage2Text3",
- "0\n-1\n",
- "0\n-1\n",
- $this->textId2 . "\n23\nFetchTextTestPage2Text1",
- $this->textId3 . "\n23\nFetchTextTestPage2Text2"
- ) ) );
+ "0\n-1\n",
+ $this->textId4 . "\n23\nFetchTextTestPage2Text3",
+ "0\n-1\n",
+ "0\n-1\n",
+ $this->textId2 . "\n23\nFetchTextTestPage2Text1",
+ $this->textId3 . "\n23\nFetchTextTestPage2Text2"
+ ) ) );
}
}