From: Siebrand Mazeland Date: Thu, 24 Apr 2014 17:52:51 +0000 (+0200) Subject: Pass phpcs-strict on some test files (11/11) X-Git-Tag: 1.31.0-rc.0~16020^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=4ede8c2e9dedf97d4f8a9fd35f7b72dd3e66d9f3;p=lhc%2Fweb%2Fwiklou.git Pass phpcs-strict on some test files (11/11) Woo! Change-Id: I9fc116dfdf18c2772d047adb5bb14535d0bd39ed --- diff --git a/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php b/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php index 71d32c3f87..8e3b1145cf 100644 --- a/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php +++ b/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php @@ -110,7 +110,9 @@ class CLDRPluralRuleEvaluatorTest extends MediaWikiTestCase { # Revision 33 samples # expected, rule, number, comment + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong array( 0, 'n in 1,3,5@integer 3~10, 103~110, 1003, … @decimal 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 103.0, 1003.0, …', 3, 'samples' ), + // @codingStandardsIgnoreEnd # Revision 33 some test cases from CLDR array( 0, 'i = 1 and v = 0 or i = 0 and t = 1', '0.1', 'pt one' ), @@ -122,6 +124,7 @@ class CLDRPluralRuleEvaluatorTest extends MediaWikiTestCase { array( 1, 'i = 1 and v = 0 or i = 0 and t = 1', '0.2', 'pt other' ), array( 1, 'i = 1 and v = 0 or i = 0 and t = 1', '10.0', 'pt other' ), array( 1, 'i = 1 and v = 0 or i = 0 and t = 1', '100.0', 'pt other' ), + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '2', 'bs few' ), array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '4', 'bs few' ), array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '22', 'bs few' ), @@ -130,7 +133,7 @@ class CLDRPluralRuleEvaluatorTest extends MediaWikiTestCase { array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '0.4', 'bs few' ), array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '10.2', 'bs few' ), array( 1, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '10.0', 'bs other' ), - + // @codingStandardsIgnoreEnd ); return $tests; diff --git a/tests/phpunit/maintenance/DumpTestCase.php b/tests/phpunit/maintenance/DumpTestCase.php index eff90f0d4c..4f0d24fbb5 100644 --- a/tests/phpunit/maintenance/DumpTestCase.php +++ b/tests/phpunit/maintenance/DumpTestCase.php @@ -35,16 +35,22 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { * @throws MWExcepion */ protected function addRevision( Page $page, $text, $summary ) { - $status = $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), $summary ); + $status = $page->doEditContent( + ContentHandler::makeContent( $text, $page->getTitle() ), + $summary + ); + if ( $status->isGood() ) { $value = $status->getValue(); $revision = $value['revision']; $revision_id = $revision->getId(); $text_id = $revision->getTextId(); + if ( ( $revision_id > 0 ) && ( $text_id > 0 ) ) { return array( $revision_id, $text_id ); } } + throw new MWException( "Could not determine revision id (" . $status->getWikiText() . ")" ); } @@ -105,7 +111,10 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { $this->assertEquals( '', array_pop( $lines ), "Output ends in LF" ); $timestamp_re = "[0-9]{4}-[01][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-6][0-9]"; foreach ( $lines as $line ) { - $this->assertRegExp( "/$timestamp_re: .* \(ID [0-9]+\) [0-9]* pages .*, [0-9]* revs .*, ETA/", $line ); + $this->assertRegExp( + "/$timestamp_re: .* \(ID [0-9]+\) [0-9]* pages .*, [0-9]* revs .*, ETA/", + $line + ); } } @@ -299,7 +308,8 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { * @param string $format The expected format model id (default: CONTENT_FORMAT_WIKITEXT) * @param int|bool $parentid (optional) id of the parent revision */ - protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false, $parentid = false, + protected function assertRevision( $id, $summary, $text_id, $text_bytes, + $text_sha1, $text = false, $parentid = false, $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT ) { $this->assertNodeStart( "revision" ); diff --git a/tests/phpunit/maintenance/backupPrefetchTest.php b/tests/phpunit/maintenance/backupPrefetchTest.php index 904f12f869..744cf616aa 100644 --- a/tests/phpunit/maintenance/backupPrefetchTest.php +++ b/tests/phpunit/maintenance/backupPrefetchTest.php @@ -151,6 +151,7 @@ class BaseDumpTest extends MediaWikiTestCase { $fname = $this->getNewTempFile(); // The header of every prefetch file + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong $header = ' wikisvn @@ -179,6 +180,7 @@ class BaseDumpTest extends MediaWikiTestCase { '; + // @codingStandardsIgnoreEnd // An array holding the pages that are available for prefetch $available_pages = array(); diff --git a/tests/phpunit/maintenance/backupTextPassTest.php b/tests/phpunit/maintenance/backupTextPassTest.php index a7630713f5..016b7e0cf1 100644 --- a/tests/phpunit/maintenance/backupTextPassTest.php +++ b/tests/phpunit/maintenance/backupTextPassTest.php @@ -389,7 +389,12 @@ class TextPassDumperTest extends DumpTestCase { $this->assertEmpty( $files, "Remaining unchecked files" ); // ... and have dealt with more than one checkpoint file - $this->assertGreaterThan( 1, $checkpointFiles, "expected more than 1 checkpoint to have been created. Checkpoint interval is $checkpointAfter seconds, maybe your computer is too fast?" ); + $this->assertGreaterThan( + 1, + $checkpointFiles, + "expected more than 1 checkpoint to have been created. " + . "Checkpoint interval is $checkpointAfter seconds, maybe your computer is too fast?" + ); $this->expectETAOutput(); } diff --git a/tests/phpunit/maintenance/backup_PageTest.php b/tests/phpunit/maintenance/backup_PageTest.php index 69636010ed..0cb0cdb65d 100644 --- a/tests/phpunit/maintenance/backup_PageTest.php +++ b/tests/phpunit/maintenance/backup_PageTest.php @@ -137,7 +137,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $this->assertPageStart( + $this->pageId4, + $this->talk_namespace, + $this->pageTitle4->getPrefixedText() + ); $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe", "Talk about BackupDumperTestP1 Text1" ); @@ -183,7 +187,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $this->assertPageStart( + $this->pageId4, + $this->talk_namespace, + $this->pageTitle4->getPrefixedText() + ); $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" ); $this->assertPageEnd(); @@ -222,7 +230,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $this->assertPageStart( + $this->pageId4, + $this->talk_namespace, + $this->pageTitle4->getPrefixedText() + ); $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" ); $this->assertPageEnd(); @@ -264,7 +276,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $this->assertPageStart( + $this->pageId4, + $this->talk_namespace, + $this->pageTitle4->getPrefixedText() + ); $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" ); $this->assertPageEnd(); @@ -339,7 +355,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $this->assertPageStart( + $this->pageId4, + $this->talk_namespace, + $this->pageTitle4->getPrefixedText() + ); $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" ); $this->assertPageEnd(); @@ -367,7 +387,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $this->assertPageStart( + $this->pageId4, + $this->talk_namespace, + $this->pageTitle4->getPrefixedText() + ); $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" ); $this->assertPageEnd(); diff --git a/tests/phpunit/maintenance/fetchTextTest.php b/tests/phpunit/maintenance/fetchTextTest.php index 2e47e0c2cd..8c40ffe1a5 100644 --- a/tests/phpunit/maintenance/fetchTextTest.php +++ b/tests/phpunit/maintenance/fetchTextTest.php @@ -105,15 +105,21 @@ class FetchTextTest extends MediaWikiTestCase { * @throws MWExcepion */ private function addRevision( $page, $text, $summary ) { - $status = $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), $summary ); + $status = $page->doEditContent( + ContentHandler::makeContent( $text, $page->getTitle() ), + $summary + ); + if ( $status->isGood() ) { $value = $status->getValue(); $revision = $value['revision']; $id = $revision->getTextId(); + if ( $id > 0 ) { return $id; } } + throw new MWException( "Could not determine text id" ); } @@ -127,14 +133,34 @@ class FetchTextTest extends MediaWikiTestCase { try { $title = Title::newFromText( 'FetchTextTestPage1', $wikitextNamespace ); $page = WikiPage::factory( $title ); - $this->textId1 = $this->addRevision( $page, "FetchTextTestPage1Text1", "FetchTextTestPage1Summary1" ); + $this->textId1 = $this->addRevision( + $page, + "FetchTextTestPage1Text1", + "FetchTextTestPage1Summary1" + ); $title = Title::newFromText( 'FetchTextTestPage2', $wikitextNamespace ); $page = WikiPage::factory( $title ); - $this->textId2 = $this->addRevision( $page, "FetchTextTestPage2Text1", "FetchTextTestPage2Summary1" ); - $this->textId3 = $this->addRevision( $page, "FetchTextTestPage2Text2", "FetchTextTestPage2Summary2" ); - $this->textId4 = $this->addRevision( $page, "FetchTextTestPage2Text3", "FetchTextTestPage2Summary3" ); - $this->textId5 = $this->addRevision( $page, "FetchTextTestPage2Text4 some additional Text ", "FetchTextTestPage2Summary4 extra " ); + $this->textId2 = $this->addRevision( + $page, + "FetchTextTestPage2Text1", + "FetchTextTestPage2Summary1" + ); + $this->textId3 = $this->addRevision( + $page, + "FetchTextTestPage2Text2", + "FetchTextTestPage2Summary2" + ); + $this->textId4 = $this->addRevision( + $page, + "FetchTextTestPage2Text3", + "FetchTextTestPage2Summary3" + ); + $this->textId5 = $this->addRevision( + $page, + "FetchTextTestPage2Text4 some additional Text ", + "FetchTextTestPage2Summary4 extra " + ); } catch ( Exception $e ) { // We'd love to pass $e directly. However, ... see // documentation of exceptionFromAddDBData diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php index 8e2bc0359d..2b77752c4b 100755 --- a/tests/phpunit/phpunit.php +++ b/tests/phpunit/phpunit.php @@ -6,7 +6,8 @@ * @file */ -// Set a flag which can be used to detect when other scripts have been entered through this entry point or not +// Set a flag which can be used to detect when other scripts have been entered +// through this entry point or not. define( 'MW_PHPUNIT_TEST', true ); // Start up MediaWiki in command-line mode @@ -16,8 +17,10 @@ class PHPUnitMaintClass extends Maintenance { public function __construct() { parent::__construct(); - $this->addOption( 'with-phpunitdir', - 'Directory to include PHPUnit from, for example when using a git fetchout from upstream. Path will be prepended to PHP `include_path`.', + $this->addOption( + 'with-phpunitdir', + 'Directory to include PHPUnit from, for example when using a git ' + . 'fetchout from upstream. Path will be prepended to PHP `include_path`.', false, # not required true # need arg ); diff --git a/tests/phpunit/structure/AutoLoaderTest.php b/tests/phpunit/structure/AutoLoaderTest.php index be18a49d33..12f147e9bd 100644 --- a/tests/phpunit/structure/AutoLoaderTest.php +++ b/tests/phpunit/structure/AutoLoaderTest.php @@ -10,9 +10,13 @@ class AutoLoaderTest extends MediaWikiTestCase { $this->testLocalClasses = array( 'TestAutoloadedLocalClass' => __DIR__ . '/../data/autoloader/TestAutoloadedLocalClass.php', 'TestAutoloadedCamlClass' => __DIR__ . '/../data/autoloader/TestAutoloadedCamlClass.php', - 'TestAutoloadedSerializedClass' => __DIR__ . '/../data/autoloader/TestAutoloadedSerializedClass.php', + 'TestAutoloadedSerializedClass' => + __DIR__ . '/../data/autoloader/TestAutoloadedSerializedClass.php', + ); + $this->setMwGlobals( + 'wgAutoloadLocalClasses', + $this->testLocalClasses + $wgAutoloadLocalClasses ); - $this->setMwGlobals( 'wgAutoloadLocalClasses', $this->testLocalClasses + $wgAutoloadLocalClasses ); AutoLoader::resetAutoloadLocalClassesLower(); $this->testExtensionClasses = array( diff --git a/tests/phpunit/structure/ResourcesTest.php b/tests/phpunit/structure/ResourcesTest.php index cfcc771486..d7742a6976 100644 --- a/tests/phpunit/structure/ResourcesTest.php +++ b/tests/phpunit/structure/ResourcesTest.php @@ -31,7 +31,10 @@ class ResourcesTest extends MediaWikiTestCase { public function testStyleMedia( $moduleName, $media, $filename, $css ) { $cssText = CSSMin::minify( $css->cssText ); - $this->assertTrue( strpos( $cssText, '@media' ) === false, 'Stylesheets should not both specify "media" and contain @media' ); + $this->assertTrue( + strpos( $cssText, '@media' ) === false, + 'Stylesheets should not both specify "media" and contain @media' + ); } public function testDependencies() { diff --git a/tests/phpunit/suites/ExtensionsTestSuite.php b/tests/phpunit/suites/ExtensionsTestSuite.php index 7f41e5224c..4d24d9d3a8 100644 --- a/tests/phpunit/suites/ExtensionsTestSuite.php +++ b/tests/phpunit/suites/ExtensionsTestSuite.php @@ -1,7 +1,8 @@