Pass phpcs-strict on some test files (11/11)
authorSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 17:52:51 +0000 (19:52 +0200)
committerChad Horohoe <chadh@wikimedia.org>
Thu, 24 Apr 2014 20:51:05 +0000 (13:51 -0700)
Woo!

Change-Id: I9fc116dfdf18c2772d047adb5bb14535d0bd39ed

tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php
tests/phpunit/maintenance/DumpTestCase.php
tests/phpunit/maintenance/backupPrefetchTest.php
tests/phpunit/maintenance/backupTextPassTest.php
tests/phpunit/maintenance/backup_PageTest.php
tests/phpunit/maintenance/fetchTextTest.php
tests/phpunit/phpunit.php
tests/phpunit/structure/AutoLoaderTest.php
tests/phpunit/structure/ResourcesTest.php
tests/phpunit/suites/ExtensionsTestSuite.php

index 71d32c3..8e3b114 100644 (file)
@@ -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;
index eff90f0..4f0d24f 100644 (file)
@@ -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" );
index 904f12f..744cf61 100644 (file)
@@ -151,6 +151,7 @@ class BaseDumpTest extends MediaWikiTestCase {
                $fname = $this->getNewTempFile();
 
                // The header of every prefetch file
+               // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong
                $header = '<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.7/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.7/ http://www.mediawiki.org/xml/export-0.7.xsd" version="0.7" xml:lang="en">
   <siteinfo>
     <sitename>wikisvn</sitename>
@@ -179,6 +180,7 @@ class BaseDumpTest extends MediaWikiTestCase {
     </namespaces>
   </siteinfo>
 ';
+               // @codingStandardsIgnoreEnd
 
                // An array holding the pages that are available for prefetch
                $available_pages = array();
index a763071..016b7e0 100644 (file)
@@ -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();
        }
index 6963601..0cb0cdb 100644 (file)
@@ -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();
index 2e47e0c..8c40ffe 100644 (file)
@@ -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
index 8e2bc03..2b77752 100755 (executable)
@@ -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
                );
index be18a49..12f147e 100644 (file)
@@ -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(
index cfcc771..d7742a6 100644 (file)
@@ -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() {
index 7f41e52..4d24d9d 100644 (file)
@@ -1,7 +1,8 @@
 <?php
 /**
  * This test suite runs unit tests registered by extensions.
- * See https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList for details of how to register your tests.
+ * See https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList for details of
+ * how to register your tests.
  */
 
 class ExtensionsTestSuite extends PHPUnit_Framework_TestSuite {