diff options
Diffstat (limited to 'tests/phpunit/maintenance')
-rw-r--r-- | tests/phpunit/maintenance/DumpTestCase.php | 26 | ||||
-rw-r--r-- | tests/phpunit/maintenance/MaintenanceTest.php | 6 | ||||
-rw-r--r-- | tests/phpunit/maintenance/backupPrefetchTest.php | 3 | ||||
-rw-r--r-- | tests/phpunit/maintenance/backupTextPassTest.php | 7 | ||||
-rw-r--r-- | tests/phpunit/maintenance/backup_LogTest.php | 4 | ||||
-rw-r--r-- | tests/phpunit/maintenance/backup_PageTest.php | 6 | ||||
-rw-r--r-- | tests/phpunit/maintenance/fetchTextTest.php | 2 | ||||
-rw-r--r-- | tests/phpunit/maintenance/getSlaveServerTest.php | 2 |
8 files changed, 19 insertions, 37 deletions
diff --git a/tests/phpunit/maintenance/DumpTestCase.php b/tests/phpunit/maintenance/DumpTestCase.php index 40d24fc5..83d8c71d 100644 --- a/tests/phpunit/maintenance/DumpTestCase.php +++ b/tests/phpunit/maintenance/DumpTestCase.php @@ -60,11 +60,14 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { if ( $gzipped_contents === false ) { $this->fail( "Could not get contents of $fname" ); } - // We resort to use gzinflate instead of gzdecode, as gzdecode - // need not be available - $contents = gzinflate( substr( $gzipped_contents, 10, -8 ) ); - $this->assertEquals( strlen( $contents ), - file_put_contents( $fname, $contents ), "# bytes written" ); + + $contents = gzdecode( $gzipped_contents ); + + $this->assertEquals( + strlen( $contents ), + file_put_contents( $fname, $contents ), + '# bytes written' + ); } /** @@ -73,8 +76,6 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { * Clears $wgUser, and reports errors from addDBData to PHPUnit */ protected function setUp() { - global $wgUser; - parent::setUp(); // Check if any Exception is stored for rethrowing from addDBData @@ -83,7 +84,7 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { throw $this->exceptionFromAddDBData; } - $wgUser = new User(); + $this->setMwGlobals( 'wgUser', new User() ); } /** @@ -116,7 +117,7 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { * @param $name string: name of the closing element to look for * (e.g.: "mediawiki" when looking for </mediawiki>) * - * @return bool: true iff the end node could be found. false otherwise. + * @return bool: true if the end node could be found. false otherwise. */ protected function skipToNodeEnd( $name ) { while ( $this->xml->read() ) { @@ -126,6 +127,7 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { return true; } } + return false; } @@ -147,6 +149,7 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { return true; } } + return false; } @@ -273,7 +276,6 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { $this->assertTextNode( "title", $name ); $this->assertTextNode( "ns", $ns ); $this->assertTextNode( "id", $id ); - } /** @@ -301,8 +303,8 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { * @param $parentid int|false: (optional) id of the parent revision */ protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false, $parentid = false, - $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT ) { - + $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT + ) { $this->assertNodeStart( "revision" ); $this->skipWhitespace(); diff --git a/tests/phpunit/maintenance/MaintenanceTest.php b/tests/phpunit/maintenance/MaintenanceTest.php index 741f8b7f..318ce0da 100644 --- a/tests/phpunit/maintenance/MaintenanceTest.php +++ b/tests/phpunit/maintenance/MaintenanceTest.php @@ -43,7 +43,7 @@ class MaintenanceFixup extends Maintenance { private $testCase; /** - * shutdownSimulated === true iff simulateShutdown has done it's work + * shutdownSimulated === true if simulateShutdown has done it's work * * @var bool */ @@ -128,7 +128,6 @@ class MaintenanceFixup extends Maintenance { public function execute() { $this->testCase->fail( __METHOD__ . " called unexpectedly" ); } - } class MaintenanceTest extends MediaWikiTestCase { @@ -186,7 +185,6 @@ class MaintenanceTest extends MediaWikiTestCase { // test.*Intermittent.* tests), the objective of these tests is not to describe // consistent behavior, but rather currently existing behavior. - function testOutputEmpty() { $this->m->output( "" ); $this->assertOutputPrePostShutdown( "", false ); @@ -815,6 +813,4 @@ class MaintenanceTest extends MediaWikiTestCase { $m2->simulateShutdown(); $this->assertOutputPrePostShutdown( "foobar\n\n", false ); } - - } diff --git a/tests/phpunit/maintenance/backupPrefetchTest.php b/tests/phpunit/maintenance/backupPrefetchTest.php index cc00e6e5..bc2d7375 100644 --- a/tests/phpunit/maintenance/backupPrefetchTest.php +++ b/tests/phpunit/maintenance/backupPrefetchTest.php @@ -36,7 +36,6 @@ class BaseDumpTest extends MediaWikiTestCase { private function assertPrefetchEquals( $expected, $page, $revision ) { $this->assertEquals( $expected, $this->dump->prefetch( $page, $revision ), "Prefetch of page $page revision $revision" ); - } function testSequential() { @@ -181,7 +180,6 @@ class BaseDumpTest extends MediaWikiTestCase { </siteinfo> '; - // An array holding the pages that are available for prefetch $available_pages = array(); @@ -274,5 +272,4 @@ class BaseDumpTest extends MediaWikiTestCase { return $fname; } - } diff --git a/tests/phpunit/maintenance/backupTextPassTest.php b/tests/phpunit/maintenance/backupTextPassTest.php index 09623445..653a1145 100644 --- a/tests/phpunit/maintenance/backupTextPassTest.php +++ b/tests/phpunit/maintenance/backupTextPassTest.php @@ -63,7 +63,7 @@ class TextPassDumperTest extends DumpTestCase { // Page from non-default namespace if ( $ns === NS_TALK ) { - //@todo: work around this. + // @todo work around this. throw new MWException( "The default wikitext namespace is the talk namespace. " . " We can't currently deal with that." ); } @@ -80,7 +80,6 @@ class TextPassDumperTest extends DumpTestCase { // DumpTestCase $this->exceptionFromAddDBData = $e; } - } protected function setUp() { @@ -94,7 +93,6 @@ class TextPassDumperTest extends DumpTestCase { array( $this->pageId2, $this->pageId3, $this->pageId4 ), array( $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ), "Page ids increasing without holes" ); - } function testPlain() { @@ -214,7 +212,6 @@ class TextPassDumperTest extends DumpTestCase { $this->assertPageEnd(); $this->assertDumpEnd(); - } /** @@ -239,7 +236,6 @@ class TextPassDumperTest extends DumpTestCase { $minDuration = 2; // We want the dump to take at least this many seconds $checkpointAfter = 0.5; // Generate checkpoint after this many seconds - // Until a dump takes at least $minDuration seconds, perform a dump and check // duration. If the dump did not take long enough increase the iteration // count, to generate a bigger stub file next time. @@ -579,6 +575,7 @@ class TextPassDumperTest extends DumpTestCase { $content .= $tail; $this->assertEquals( strlen( $content ), file_put_contents( $fname, $content ), "Length of prepared stub" ); + return $fname; } } diff --git a/tests/phpunit/maintenance/backup_LogTest.php b/tests/phpunit/maintenance/backup_LogTest.php index 5cf172e6..98d81653 100644 --- a/tests/phpunit/maintenance/backup_LogTest.php +++ b/tests/phpunit/maintenance/backup_LogTest.php @@ -39,6 +39,7 @@ class BackupDumperLoggerTest extends DumpTestCase { if ( $parameters !== null ) { $logEntry->setParameters( $parameters ); } + return $logEntry->insert(); } @@ -75,14 +76,12 @@ class BackupDumperLoggerTest extends DumpTestCase { $user2, NS_MAIN, "PageA", "SomeOtherComment", array( 'key1' => 1, 3 => 'value3' ) ); $this->assertGreaterThan( 0, $this->logId3 ); - } catch ( Exception $e ) { // We'd love to pass $e directly. However, ... see // documentation of exceptionFromAddDBData in // DumpTestCase $this->exceptionFromAddDBData = $e; } - } @@ -226,5 +225,4 @@ class BackupDumperLoggerTest extends DumpTestCase { // the following statement to catch good output $this->expectOutputString( '' ); } - } diff --git a/tests/phpunit/maintenance/backup_PageTest.php b/tests/phpunit/maintenance/backup_PageTest.php index 07c76705..99bd2700 100644 --- a/tests/phpunit/maintenance/backup_PageTest.php +++ b/tests/phpunit/maintenance/backup_PageTest.php @@ -34,7 +34,7 @@ class BackupDumperPageTest extends DumpTestCase { $this->talk_namespace = NS_TALK; if ( $this->namespace === $this->talk_namespace ) { - //@todo: work around this. + // @todo work around this. throw new MWException( "The default wikitext namespace is the talk namespace. " . " We can't currently deal with that." ); } @@ -79,7 +79,6 @@ class BackupDumperPageTest extends DumpTestCase { // DumpTestCase $this->exceptionFromAddDBData = $e; } - } protected function setUp() { @@ -93,7 +92,6 @@ class BackupDumperPageTest extends DumpTestCase { array( $this->pageId2, $this->pageId3, $this->pageId4 ), array( $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ), "Page ids increasing without holes" ); - } function testFullTextPlain() { @@ -403,6 +401,4 @@ class BackupDumperPageTest extends DumpTestCase { $this->expectETAOutput(); } - - } diff --git a/tests/phpunit/maintenance/fetchTextTest.php b/tests/phpunit/maintenance/fetchTextTest.php index 4d1d45d6..e8df199e 100644 --- a/tests/phpunit/maintenance/fetchTextTest.php +++ b/tests/phpunit/maintenance/fetchTextTest.php @@ -63,7 +63,6 @@ class SemiMockedFetchText extends FetchText { return fopen( 'data://text/plain,' . $this->mockStdinText, 'r' ); } - } /** @@ -236,5 +235,4 @@ class FetchTextTest extends MediaWikiTestCase { $this->textId3 . "\n23\nFetchTextTestPage2Text2" ) ) ); } - } diff --git a/tests/phpunit/maintenance/getSlaveServerTest.php b/tests/phpunit/maintenance/getSlaveServerTest.php index 699571b7..2c848862 100644 --- a/tests/phpunit/maintenance/getSlaveServerTest.php +++ b/tests/phpunit/maintenance/getSlaveServerTest.php @@ -64,6 +64,4 @@ class GetSlaveServerTest extends MediaWikiTestCase { $this->expectOutputRegex( "/^[[:space:]]*\[wgDBprefix\][[:space:]]*=> " . $wgDBprefix . "$/m" ); } - - } |