Pass phpcs-strict on some test files (3/x)
authorSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 12:35:05 +0000 (14:35 +0200)
committerSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 16:51:39 +0000 (18:51 +0200)
Change-Id: I44172b512cd9b6c43806dad697e449bf06897305

12 files changed:
tests/phpunit/includes/LocalFileTest.php
tests/phpunit/includes/MessageTest.php
tests/phpunit/includes/PathRouterTest.php
tests/phpunit/includes/RequestContextTest.php
tests/phpunit/includes/RevisionStorageTest.php
tests/phpunit/includes/RevisionStorageTestContentHandlerUseDB.php [new file with mode: 0644]
tests/phpunit/includes/RevisionStorageTest_ContentHandlerUseDB.php [deleted file]
tests/phpunit/includes/RevisionTest.php
tests/phpunit/includes/SampleTest.php
tests/phpunit/includes/SanitizerTest.php
tests/phpunit/includes/SiteConfigurationTest.php
tests/phpunit/includes/SkinTemplateTest.php

index d210ce5..5c5052e 100644 (file)
@@ -67,20 +67,44 @@ class LocalFileTest extends MediaWikiTestCase {
         * @covers File::getArchivePath
         */
        public function testGetArchivePath() {
-               $this->assertEquals( 'mwstore://local-backend/test-public/archive', $this->file_hl0->getArchivePath() );
-               $this->assertEquals( 'mwstore://local-backend/test-public/archive/a/a2', $this->file_hl2->getArchivePath() );
-               $this->assertEquals( 'mwstore://local-backend/test-public/archive/!', $this->file_hl0->getArchivePath( '!' ) );
-               $this->assertEquals( 'mwstore://local-backend/test-public/archive/a/a2/!', $this->file_hl2->getArchivePath( '!' ) );
+               $this->assertEquals(
+                       'mwstore://local-backend/test-public/archive',
+                       $this->file_hl0->getArchivePath()
+               );
+               $this->assertEquals(
+                       'mwstore://local-backend/test-public/archive/a/a2',
+                       $this->file_hl2->getArchivePath()
+               );
+               $this->assertEquals(
+                       'mwstore://local-backend/test-public/archive/!',
+                       $this->file_hl0->getArchivePath( '!' )
+               );
+               $this->assertEquals(
+                       'mwstore://local-backend/test-public/archive/a/a2/!',
+                       $this->file_hl2->getArchivePath( '!' )
+               );
        }
 
        /**
         * @covers File::getThumbPath
         */
        public function testGetThumbPath() {
-               $this->assertEquals( 'mwstore://local-backend/test-thumb/Test!', $this->file_hl0->getThumbPath() );
-               $this->assertEquals( 'mwstore://local-backend/test-thumb/a/a2/Test!', $this->file_hl2->getThumbPath() );
-               $this->assertEquals( 'mwstore://local-backend/test-thumb/Test!/x', $this->file_hl0->getThumbPath( 'x' ) );
-               $this->assertEquals( 'mwstore://local-backend/test-thumb/a/a2/Test!/x', $this->file_hl2->getThumbPath( 'x' ) );
+               $this->assertEquals(
+                       'mwstore://local-backend/test-thumb/Test!',
+                       $this->file_hl0->getThumbPath()
+               );
+               $this->assertEquals(
+                       'mwstore://local-backend/test-thumb/a/a2/Test!',
+                       $this->file_hl2->getThumbPath()
+               );
+               $this->assertEquals(
+                       'mwstore://local-backend/test-thumb/Test!/x',
+                       $this->file_hl0->getThumbPath( 'x' )
+               );
+               $this->assertEquals(
+                       'mwstore://local-backend/test-thumb/a/a2/Test!/x',
+                       $this->file_hl2->getThumbPath( 'x' )
+               );
        }
 
        /**
@@ -108,9 +132,18 @@ class LocalFileTest extends MediaWikiTestCase {
         */
        public function testGetArchiveVirtualUrl() {
                $this->assertEquals( 'mwrepo://test/public/archive', $this->file_hl0->getArchiveVirtualUrl() );
-               $this->assertEquals( 'mwrepo://test/public/archive/a/a2', $this->file_hl2->getArchiveVirtualUrl() );
-               $this->assertEquals( 'mwrepo://test/public/archive/%21', $this->file_hl0->getArchiveVirtualUrl( '!' ) );
-               $this->assertEquals( 'mwrepo://test/public/archive/a/a2/%21', $this->file_hl2->getArchiveVirtualUrl( '!' ) );
+               $this->assertEquals(
+                       'mwrepo://test/public/archive/a/a2',
+                       $this->file_hl2->getArchiveVirtualUrl()
+               );
+               $this->assertEquals(
+                       'mwrepo://test/public/archive/%21',
+                       $this->file_hl0->getArchiveVirtualUrl( '!' )
+               );
+               $this->assertEquals(
+                       'mwrepo://test/public/archive/a/a2/%21',
+                       $this->file_hl2->getArchiveVirtualUrl( '!' )
+               );
        }
 
        /**
@@ -119,8 +152,14 @@ class LocalFileTest extends MediaWikiTestCase {
        public function testGetThumbVirtualUrl() {
                $this->assertEquals( 'mwrepo://test/thumb/Test%21', $this->file_hl0->getThumbVirtualUrl() );
                $this->assertEquals( 'mwrepo://test/thumb/a/a2/Test%21', $this->file_hl2->getThumbVirtualUrl() );
-               $this->assertEquals( 'mwrepo://test/thumb/Test%21/%21', $this->file_hl0->getThumbVirtualUrl( '!' ) );
-               $this->assertEquals( 'mwrepo://test/thumb/a/a2/Test%21/%21', $this->file_hl2->getThumbVirtualUrl( '!' ) );
+               $this->assertEquals(
+                       'mwrepo://test/thumb/Test%21/%21',
+                       $this->file_hl0->getThumbVirtualUrl( '!' )
+               );
+               $this->assertEquals(
+                       'mwrepo://test/thumb/a/a2/Test%21/%21',
+                       $this->file_hl2->getThumbVirtualUrl( '!' )
+               );
        }
 
        /**
@@ -136,6 +175,10 @@ class LocalFileTest extends MediaWikiTestCase {
         */
        public function testWfLocalFile() {
                $file = wfLocalFile( "File:Some_file_that_probably_doesn't exist.png" );
-               $this->assertThat( $file, $this->isInstanceOf( 'LocalFile' ), 'wfLocalFile() returns LocalFile for valid Titles' );
+               $this->assertThat(
+                       $file,
+                       $this->isInstanceOf( 'LocalFile' ),
+                       'wfLocalFile() returns LocalFile for valid Titles'
+               );
        }
 }
index 25b0805..7db985b 100644 (file)
@@ -124,7 +124,10 @@ class MessageTest extends MediaWikiLangTestCase {
                // NOTE: make sure internal caching of the message text is reset appropriately
                $msg = wfMessage( 'mainpage' );
                $this->assertEquals( 'Main Page', $msg->inLanguage( Language::factory( 'en' ) )->text() );
-               $this->assertEquals( 'Заглавная страница', $msg->inLanguage( Language::factory( 'ru' ) )->text() );
+               $this->assertEquals(
+                       'Заглавная страница',
+                       $msg->inLanguage( Language::factory( 'ru' ) )->text()
+               );
        }
 
        /**
@@ -133,8 +136,14 @@ class MessageTest extends MediaWikiLangTestCase {
        public function testMessageParams() {
                $this->assertEquals( 'Return to $1.', wfMessage( 'returnto' )->text() );
                $this->assertEquals( 'Return to $1.', wfMessage( 'returnto', array() )->text() );
-               $this->assertEquals( 'You have foo (bar).', wfMessage( 'youhavenewmessages', 'foo', 'bar' )->text() );
-               $this->assertEquals( 'You have foo (bar).', wfMessage( 'youhavenewmessages', array( 'foo', 'bar' ) )->text() );
+               $this->assertEquals(
+                       'You have foo (bar).',
+                       wfMessage( 'youhavenewmessages', 'foo', 'bar' )->text()
+               );
+               $this->assertEquals(
+                       'You have foo (bar).',
+                       wfMessage( 'youhavenewmessages', array( 'foo', 'bar' ) )->text()
+               );
        }
 
        /**
@@ -142,10 +151,22 @@ class MessageTest extends MediaWikiLangTestCase {
         * @covers Message::rawParams
         */
        public function testMessageParamSubstitution() {
-               $this->assertEquals( '(Заглавная страница)', wfMessage( 'parentheses', 'Заглавная страница' )->plain() );
-               $this->assertEquals( '(Заглавная страница $1)', wfMessage( 'parentheses', 'Заглавная страница $1' )->plain() );
-               $this->assertEquals( '(Заглавная страница)', wfMessage( 'parentheses' )->rawParams( 'Заглавная страница' )->plain() );
-               $this->assertEquals( '(Заглавная страница $1)', wfMessage( 'parentheses' )->rawParams( 'Заглавная страница $1' )->plain() );
+               $this->assertEquals(
+                       '(Заглавная страница)',
+                       wfMessage( 'parentheses', 'Заглавная страница' )->plain()
+               );
+               $this->assertEquals(
+                       '(Заглавная страница $1)',
+                       wfMessage( 'parentheses', 'Заглавная страница $1' )->plain()
+               );
+               $this->assertEquals(
+                       '(Заглавная страница)',
+                       wfMessage( 'parentheses' )->rawParams( 'Заглавная страница' )->plain()
+               );
+               $this->assertEquals(
+                       '(Заглавная страница $1)',
+                       wfMessage( 'parentheses' )->rawParams( 'Заглавная страница $1' )->plain()
+               );
        }
 
        /**
@@ -156,7 +177,11 @@ class MessageTest extends MediaWikiLangTestCase {
                $msg = new RawMessage( '$1$2$3$4$5$6$7$8$9$10$11$12' );
                // One less than above has placeholders
                $params = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k' );
-               $this->assertEquals( 'abcdefghijka2', $msg->params( $params )->plain(), 'Params > 9 are replaced correctly' );
+               $this->assertEquals(
+                       'abcdefghijka2',
+                       $msg->params( $params )->plain(),
+                       'Params > 9 are replaced correctly'
+               );
        }
 
        /**
@@ -270,9 +295,17 @@ class MessageTest extends MediaWikiLangTestCase {
                // NOTE: make sure internal caching of the message text is reset appropriately.
                // NOTE: wgForceUIMsgAsContentMsg forces the messages *current* language to be used.
                $msg = wfMessage( 'mainpage' );
-               $this->assertEquals( 'Accueil', $msg->inContentLanguage()->plain(), 'inContentLanguage() with ForceUIMsg override enabled' );
+               $this->assertEquals(
+                       'Accueil',
+                       $msg->inContentLanguage()->plain(),
+                       'inContentLanguage() with ForceUIMsg override enabled'
+               );
                $this->assertEquals( 'Main Page', $msg->inLanguage( 'en' )->plain(), "inLanguage( 'en' )" );
-               $this->assertEquals( 'Main Page', $msg->inContentLanguage()->plain(), 'inContentLanguage() with ForceUIMsg override enabled' );
+               $this->assertEquals(
+                       'Main Page',
+                       $msg->inContentLanguage()->plain(),
+                       'inContentLanguage() with ForceUIMsg override enabled'
+               );
                $this->assertEquals( 'Hauptseite', $msg->inLanguage( 'de' )->plain(), "inLanguage( 'de' )" );
        }
 
index e60dc54..0d78268 100644 (file)
@@ -236,8 +236,10 @@ class PathRouterTest extends MediaWikiTestCase {
         * Ensure the router doesn't choke on long paths.
         */
        public function testLength() {
+               // @codingStandardsIgnoreStart Ignore long line warnings
                $matches = $this->basicRouter->parse( "/wiki/Lorem_ipsum_dolor_sit_amet,_consectetur_adipisicing_elit,_sed_do_eiusmod_tempor_incididunt_ut_labore_et_dolore_magna_aliqua._Ut_enim_ad_minim_veniam,_quis_nostrud_exercitation_ullamco_laboris_nisi_ut_aliquip_ex_ea_commodo_consequat._Duis_aute_irure_dolor_in_reprehenderit_in_voluptate_velit_esse_cillum_dolore_eu_fugiat_nulla_pariatur._Excepteur_sint_occaecat_cupidatat_non_proident,_sunt_in_culpa_qui_officia_deserunt_mollit_anim_id_est_laborum." );
                $this->assertEquals( $matches, array( 'title' => "Lorem_ipsum_dolor_sit_amet,_consectetur_adipisicing_elit,_sed_do_eiusmod_tempor_incididunt_ut_labore_et_dolore_magna_aliqua._Ut_enim_ad_minim_veniam,_quis_nostrud_exercitation_ullamco_laboris_nisi_ut_aliquip_ex_ea_commodo_consequat._Duis_aute_irure_dolor_in_reprehenderit_in_voluptate_velit_esse_cillum_dolore_eu_fugiat_nulla_pariatur._Excepteur_sint_occaecat_cupidatat_non_proident,_sunt_in_culpa_qui_officia_deserunt_mollit_anim_id_est_laborum." ) );
+               // @codingStandardsIgnoreEnd
        }
 
        /**
index 1776b5d..f595d2d 100644 (file)
@@ -25,8 +25,11 @@ class RequestContextTest extends MediaWikiTestCase {
 
                $curTitle = Title::newFromText( "C" );
                $context->setTitle( $curTitle );
-               $this->assertTrue( $curTitle->equals( $context->getWikiPage()->getTitle() ),
-                       "When a title is updated the WikiPage should be purged and recreated on-demand with the new title." );
+               $this->assertTrue(
+                       $curTitle->equals( $context->getWikiPage()->getTitle() ),
+                       "When a title is updated the WikiPage should be purged "
+                               . "and recreated on-demand with the new title."
+               );
        }
 
        /**
@@ -46,7 +49,9 @@ class RequestContextTest extends MediaWikiTestCase {
                        'sessionId' => 'd612ee607c87e749ef14da4983a702cd',
                        'userId' => $user->getId(),
                        'ip' => '192.0.2.0',
-                       'headers' => array( 'USER-AGENT' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0' )
+                       'headers' => array(
+                               'USER-AGENT' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0'
+                       )
                );
                $sc = RequestContext::importScopedSession( $sinfo ); // load new context
 
@@ -55,12 +60,24 @@ class RequestContextTest extends MediaWikiTestCase {
                $this->assertEquals( $sinfo['headers'], $info['headers'], "Correct headers." );
                $this->assertEquals( $sinfo['sessionId'], $info['sessionId'], "Correct session ID." );
                $this->assertEquals( $sinfo['userId'], $info['userId'], "Correct user ID." );
-               $this->assertEquals( $sinfo['ip'], $context->getRequest()->getIP(), "Correct context IP address." );
-               $this->assertEquals( $sinfo['headers'], $context->getRequest()->getAllHeaders(), "Correct context headers." );
+               $this->assertEquals(
+                       $sinfo['ip'],
+                       $context->getRequest()->getIP(),
+                       "Correct context IP address."
+               );
+               $this->assertEquals(
+                       $sinfo['headers'],
+                       $context->getRequest()->getAllHeaders(),
+                       "Correct context headers."
+               );
                $this->assertEquals( $sinfo['sessionId'], session_id(), "Correct context session ID." );
                $this->assertEquals( true, $context->getUser()->isLoggedIn(), "Correct context user." );
                $this->assertEquals( $sinfo['userId'], $context->getUser()->getId(), "Correct context user ID." );
-               $this->assertEquals( 'UnitTestContextUser', $context->getUser()->getName(), "Correct context user name." );
+               $this->assertEquals(
+                       'UnitTestContextUser',
+                       $context->getUser()->getName(),
+                       "Correct context user name."
+               );
 
                unset( $sc ); // restore previous context
 
index e69660e..9a429bc 100644 (file)
  * ^--- important, causes tests not to fail with timeout
  */
 class RevisionStorageTest extends MediaWikiTestCase {
-
        /**
         * @var WikiPage $the_page
         */
-       var $the_page;
+       private $the_page;
 
        function __construct( $name = null, array $data = array(), $dataName = '' ) {
                parent::__construct( $name, $data, $dataName );
@@ -52,7 +51,11 @@ class RevisionStorageTest extends MediaWikiTestCase {
                MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
                $wgContLang->resetNamespaces(); # reset namespace cache
                if ( !$this->the_page ) {
-                       $this->the_page = $this->createPage( 'RevisionStorageTest_the_page', "just a dummy page", CONTENT_MODEL_WIKITEXT );
+                       $this->the_page = $this->createPage(
+                               'RevisionStorageTest_the_page',
+                               "just a dummy page",
+                               CONTENT_MODEL_WIKITEXT
+                       );
                }
        }
 
@@ -174,7 +177,11 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::newFromArchiveRow
         */
        public function testNewFromArchiveRow() {
-               $page = $this->createPage( 'RevisionStorageTest_testNewFromArchiveRow', 'Lorem Ipsum', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testNewFromArchiveRow',
+                       'Lorem Ipsum',
+                       CONTENT_MODEL_WIKITEXT
+               );
                $orig = $page->getRevision();
                $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
 
@@ -205,7 +212,11 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::fetchRevision
         */
        public function testFetchRevision() {
-               $page = $this->createPage( 'RevisionStorageTest_testFetchRevision', 'one', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testFetchRevision',
+                       'one',
+                       CONTENT_MODEL_WIKITEXT
+               );
 
                // Hidden process cache assertion below
                $page->getRevision()->getId();
@@ -235,7 +246,10 @@ class RevisionStorageTest extends MediaWikiTestCase {
 
                $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields' );
                $this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields' );
-               $this->assertTrue( in_array( 'rev_timestamp', $fields ), 'missing rev_timestamp in list of fields' );
+               $this->assertTrue(
+                       in_array( 'rev_timestamp', $fields ),
+                       'missing rev_timestamp in list of fields'
+               );
                $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields' );
 
                if ( $wgContentHandlerUseDB ) {
@@ -351,7 +365,11 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::isCurrent
         */
        public function testIsCurrent() {
-               $page = $this->createPage( 'RevisionStorageTest_testIsCurrent', 'Lorem Ipsum', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testIsCurrent',
+                       'Lorem Ipsum',
+                       CONTENT_MODEL_WIKITEXT
+               );
                $rev1 = $page->getRevision();
 
                # @todo find out if this should be true
@@ -360,7 +378,10 @@ class RevisionStorageTest extends MediaWikiTestCase {
                $rev1x = Revision::newFromId( $rev1->getId() );
                $this->assertTrue( $rev1x->isCurrent() );
 
-               $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ), 'second rev' );
+               $page->doEditContent(
+                       ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
+                       'second rev'
+               );
                $rev2 = $page->getRevision();
 
                # @todo find out if this should be true
@@ -377,12 +398,17 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::getPrevious
         */
        public function testGetPrevious() {
-               $page = $this->createPage( 'RevisionStorageTest_testGetPrevious', 'Lorem Ipsum testGetPrevious', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testGetPrevious',
+                       'Lorem Ipsum testGetPrevious',
+                       CONTENT_MODEL_WIKITEXT
+               );
                $rev1 = $page->getRevision();
 
                $this->assertNull( $rev1->getPrevious() );
 
-               $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
+               $page->doEditContent(
+                       ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
                        'second rev testGetPrevious' );
                $rev2 = $page->getRevision();
 
@@ -394,13 +420,19 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::getNext
         */
        public function testGetNext() {
-               $page = $this->createPage( 'RevisionStorageTest_testGetNext', 'Lorem Ipsum testGetNext', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testGetNext',
+                       'Lorem Ipsum testGetNext',
+                       CONTENT_MODEL_WIKITEXT
+               );
                $rev1 = $page->getRevision();
 
                $this->assertNull( $rev1->getNext() );
 
-               $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
-                       'second rev testGetNext' );
+               $page->doEditContent(
+                       ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
+                       'second rev testGetNext'
+               );
                $rev2 = $page->getRevision();
 
                $this->assertNotNull( $rev1->getNext() );
@@ -411,7 +443,11 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::newNullRevision
         */
        public function testNewNullRevision() {
-               $page = $this->createPage( 'RevisionStorageTest_testNewNullRevision', 'some testing text', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testNewNullRevision',
+                       'some testing text',
+                       CONTENT_MODEL_WIKITEXT
+               );
                $orig = $page->getRevision();
 
                $dbw = wfGetDB( DB_MASTER );
@@ -469,7 +505,8 @@ class RevisionStorageTest extends MediaWikiTestCase {
                # zero
                $revisions[0] = new Revision( array(
                        'page' => $page->getId(),
-                       'title' => $page->getTitle(), // we need the title to determine the page's default content model
+                       // we need the title to determine the page's default content model
+                       'title' => $page->getTitle(),
                        'timestamp' => '20120101000000',
                        'user' => $userA->getId(),
                        'text' => 'zero',
@@ -481,7 +518,8 @@ class RevisionStorageTest extends MediaWikiTestCase {
                # one
                $revisions[1] = new Revision( array(
                        'page' => $page->getId(),
-                       'title' => $page->getTitle(), // still need the title, because $page->getId() is 0 (there's no entry in the page table)
+                       // still need the title, because $page->getId() is 0 (there's no entry in the page table)
+                       'title' => $page->getTitle(),
                        'timestamp' => '20120101000100',
                        'user' => $userA->getId(),
                        'text' => 'one',
diff --git a/tests/phpunit/includes/RevisionStorageTestContentHandlerUseDB.php b/tests/phpunit/includes/RevisionStorageTestContentHandlerUseDB.php
new file mode 100644 (file)
index 0000000..d5e47c8
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+
+/**
+ * @group ContentHandler
+ * @group Database
+ * ^--- important, causes temporary tables to be used instead of the real database
+ */
+class RevisionTestContentHandlerUseDB extends RevisionStorageTest {
+
+       protected function setUp() {
+               $this->setMwGlobals( 'wgContentHandlerUseDB', false );
+
+               $dbw = wfGetDB( DB_MASTER );
+
+               $page_table = $dbw->tableName( 'page' );
+               $revision_table = $dbw->tableName( 'revision' );
+               $archive_table = $dbw->tableName( 'archive' );
+
+               if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
+                       $dbw->query( "alter table $page_table drop column page_content_model" );
+                       $dbw->query( "alter table $revision_table drop column rev_content_model" );
+                       $dbw->query( "alter table $revision_table drop column rev_content_format" );
+                       $dbw->query( "alter table $archive_table drop column ar_content_model" );
+                       $dbw->query( "alter table $archive_table drop column ar_content_format" );
+               }
+
+               parent::setUp();
+       }
+
+       /**
+        * @covers Revision::selectFields
+        */
+       public function testSelectFields() {
+               $fields = Revision::selectFields();
+
+               $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields' );
+               $this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields' );
+               $this->assertTrue(
+                       in_array( 'rev_timestamp', $fields ),
+                       'missing rev_timestamp in list of fields'
+               );
+               $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields' );
+
+               $this->assertFalse(
+                       in_array( 'rev_content_model', $fields ),
+                       'missing rev_content_model in list of fields'
+               );
+               $this->assertFalse(
+                       in_array( 'rev_content_format', $fields ),
+                       'missing rev_content_format in list of fields'
+               );
+       }
+
+       /**
+        * @covers Revision::getContentModel
+        */
+       public function testGetContentModel() {
+               try {
+                       $this->makeRevision( array( 'text' => 'hello hello.',
+                               'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
+
+                       $this->fail( "Creating JavaScript content on a wikitext page should fail with "
+                               . "\$wgContentHandlerUseDB disabled" );
+               } catch ( MWException $ex ) {
+                       $this->assertTrue( true ); // ok
+               }
+       }
+
+       /**
+        * @covers Revision::getContentFormat
+        */
+       public function testGetContentFormat() {
+               try {
+                       // @todo change this to test failure on using a non-standard (but supported) format
+                       //       for a content model supported in the given location. As of 1.21, there are
+                       //       no alternative formats for any of the standard content models that could be
+                       //       used for this though.
+
+                       $this->makeRevision( array( 'text' => 'hello hello.',
+                               'content_model' => CONTENT_MODEL_JAVASCRIPT,
+                               'content_format' => 'text/javascript' ) );
+
+                       $this->fail( "Creating JavaScript content on a wikitext page should fail with "
+                               . "\$wgContentHandlerUseDB disabled" );
+               } catch ( MWException $ex ) {
+                       $this->assertTrue( true ); // ok
+               }
+       }
+}
diff --git a/tests/phpunit/includes/RevisionStorageTest_ContentHandlerUseDB.php b/tests/phpunit/includes/RevisionStorageTest_ContentHandlerUseDB.php
deleted file mode 100644 (file)
index f830e36..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-/**
- * @group ContentHandler
- * @group Database
- * ^--- important, causes temporary tables to be used instead of the real database
- */
-class RevisionTest_ContentHandlerUseDB extends RevisionStorageTest {
-
-       protected function setUp() {
-               $this->setMwGlobals( 'wgContentHandlerUseDB', false );
-
-               $dbw = wfGetDB( DB_MASTER );
-
-               $page_table = $dbw->tableName( 'page' );
-               $revision_table = $dbw->tableName( 'revision' );
-               $archive_table = $dbw->tableName( 'archive' );
-
-               if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
-                       $dbw->query( "alter table $page_table drop column page_content_model" );
-                       $dbw->query( "alter table $revision_table drop column rev_content_model" );
-                       $dbw->query( "alter table $revision_table drop column rev_content_format" );
-                       $dbw->query( "alter table $archive_table drop column ar_content_model" );
-                       $dbw->query( "alter table $archive_table drop column ar_content_format" );
-               }
-
-               parent::setUp();
-       }
-
-       /**
-        * @covers Revision::selectFields
-        */
-       public function testSelectFields() {
-               $fields = Revision::selectFields();
-
-               $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields' );
-               $this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields' );
-               $this->assertTrue( in_array( 'rev_timestamp', $fields ), 'missing rev_timestamp in list of fields' );
-               $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields' );
-
-               $this->assertFalse( in_array( 'rev_content_model', $fields ), 'missing rev_content_model in list of fields' );
-               $this->assertFalse( in_array( 'rev_content_format', $fields ), 'missing rev_content_format in list of fields' );
-       }
-
-       /**
-        * @covers Revision::getContentModel
-        */
-       public function testGetContentModel() {
-               try {
-                       $this->makeRevision( array( 'text' => 'hello hello.',
-                               'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
-
-                       $this->fail( "Creating JavaScript content on a wikitext page should fail with "
-                               . "\$wgContentHandlerUseDB disabled" );
-               } catch ( MWException $ex ) {
-                       $this->assertTrue( true ); // ok
-               }
-       }
-
-       /**
-        * @covers Revision::getContentFormat
-        */
-       public function testGetContentFormat() {
-               try {
-                       // @todo change this to test failure on using a non-standard (but supported) format
-                       //       for a content model supported in the given location. As of 1.21, there are
-                       //       no alternative formats for any of the standard content models that could be
-                       //       used for this though.
-
-                       $this->makeRevision( array( 'text' => 'hello hello.',
-                               'content_model' => CONTENT_MODEL_JAVASCRIPT,
-                               'content_format' => 'text/javascript' ) );
-
-                       $this->fail( "Creating JavaScript content on a wikitext page should fail with "
-                               . "\$wgContentHandlerUseDB disabled" );
-               } catch ( MWException $ex ) {
-                       $this->assertTrue( true ); // ok
-               }
-       }
-}
index 48a4017..4623b38 100644 (file)
@@ -173,7 +173,7 @@ class RevisionTest extends MediaWikiTestCase {
                        Revision::getRevisionText( $row ), "getRevisionText" );
        }
 
-       # =================================================================================================================
+       # =========================================================================
 
        /**
         * @param string $text
@@ -183,7 +183,9 @@ class RevisionTest extends MediaWikiTestCase {
         *
         * @return Revision
         */
-       function newTestRevision( $text, $title = "Test", $model = CONTENT_MODEL_WIKITEXT, $format = null ) {
+       function newTestRevision( $text, $title = "Test",
+               $model = CONTENT_MODEL_WIKITEXT, $format = null
+       ) {
                if ( is_string( $title ) ) {
                        $title = Title::newFromText( $title );
                }
@@ -273,8 +275,22 @@ class RevisionTest extends MediaWikiTestCase {
                //NOTE: we expect the help namespace to always contain wikitext
                return array(
                        array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
-                       array( serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, serialize( 'hello world' ) ),
-                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, serialize( 'hello world' ) ),
+                       array(
+                               serialize( 'hello world' ),
+                               'Hello',
+                               "testing",
+                               null,
+                               Revision::FOR_PUBLIC,
+                               serialize( 'hello world' )
+                       ),
+                       array(
+                               serialize( 'hello world' ),
+                               'Dummy:Hello',
+                               null,
+                               null,
+                               Revision::FOR_PUBLIC,
+                               serialize( 'hello world' )
+                       ),
                );
        }
 
@@ -283,11 +299,16 @@ class RevisionTest extends MediaWikiTestCase {
         * @dataProvider dataGetContent
         * @covers Revision::getContent
         */
-       public function testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization ) {
+       public function testGetContent( $text, $title, $model, $format,
+               $audience, $expectedSerialization
+       ) {
                $rev = $this->newTestRevision( $text, $title, $model, $format );
                $content = $rev->getContent( $audience );
 
-               $this->assertEquals( $expectedSerialization, is_null( $content ) ? null : $content->serialize( $format ) );
+               $this->assertEquals(
+                       $expectedSerialization,
+                       is_null( $content ) ? null : $content->serialize( $format )
+               );
        }
 
        function dataGetText() {
@@ -345,7 +366,11 @@ class RevisionTest extends MediaWikiTestCase {
        public function dataGetSha1() {
                return array(
                        array( "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ),
-                       array( serialize( "hello world." ), "testing", Revision::base36Sha1( serialize( "hello world." ) ) ),
+                       array(
+                               serialize( "hello world." ),
+                               "testing",
+                               Revision::base36Sha1( serialize( "hello world." ) )
+                       ),
                );
        }
 
@@ -420,8 +445,10 @@ class RevisionTest extends MediaWikiTestCase {
                $content->setText( "bar" );
 
                $content2 = $rev->getContent( Revision::RAW );
-               $this->assertNotSame( $content, $content2, "expected a clone" ); // content is mutable, expect clone
-               $this->assertEquals( "foo", $content2->getText() ); // clone should contain the original text
+               // content is mutable, expect clone
+               $this->assertNotSame( $content, $content2, "expected a clone" );
+               // clone should contain the original text
+               $this->assertEquals( "foo", $content2->getText() );
 
                $content2->setText( "bla bla" );
                $this->assertEquals( "bar", $content->getText() ); // clones should be independent
index 7e81fab..758c2e2 100644 (file)
@@ -56,10 +56,12 @@ class TestSample extends MediaWikiLangTestCase {
                );
        }
 
+       // @codingStandardsIgnoreStart Ignore long line warning
        /**
         * @dataProvider provideTitles
-        * See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.dataProvider
+        * See http://phpunit.de/manual/3.7/en/appendixes.annotations.html#appendixes.annotations.dataProvider
         */
+       // @codingStandardsIgnoreEnd
        public function testCreateBasicListOfTitles( $titleName, $ns, $text ) {
                $title = Title::newFromText( $titleName, $ns );
                $this->assertEquals( $text, "$title", "see if '$titleName' matches '$text'" );
@@ -86,16 +88,18 @@ class TestSample extends MediaWikiLangTestCase {
 
        /**
         * @depends testSetUpMainPageTitleForNextTest
-        * See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.depends
+        * See http://phpunit.de/manual/3.7/en/appendixes.annotations.html#appendixes.annotations.depends
         */
        public function testCheckMainPageTitleIsConsideredLocal( $title ) {
                $this->assertTrue( $title->isLocal() );
        }
 
+       // @codingStandardsIgnoreStart Ignore long line warning
        /**
         * @expectedException MWException object
-        * See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.expectedException
+        * See http://phpunit.de/manual/3.7/en/appendixes.annotations.html#appendixes.annotations.expectedException
         */
+       // @codingStandardsIgnoreEnd
        public function testTitleObjectFromObject() {
                $title = Title::newFromText( Title::newFromText( "test" ) );
                $this->assertEquals( "Test", $title->isLocal() );
index f5551ed..50c1e50 100644 (file)
@@ -84,7 +84,11 @@ class SanitizerTest extends MediaWikiTestCase {
         * @covers Sanitizer::decodeCharReferences
         */
        public function testInvalidNumberedEntities() {
-               $this->assertEquals( UTF8_REPLACEMENT, Sanitizer::decodeCharReferences( "&#88888888888888;" ), 'Invalid numbered entity' );
+               $this->assertEquals(
+                       UTF8_REPLACEMENT,
+                       Sanitizer::decodeCharReferences( "&#88888888888888;" ),
+                       'Invalid numbered entity'
+               );
        }
 
        /**
@@ -180,9 +184,21 @@ class SanitizerTest extends MediaWikiTestCase {
                        array( array( 'foo' => 'bar' ), '    foo   =   bar    ', 'Spaced attribute' ),
                        array( array( 'foo' => 'bar' ), 'foo="bar"', 'Double-quoted attribute' ),
                        array( array( 'foo' => 'bar' ), 'foo=\'bar\'', 'Single-quoted attribute' ),
-                       array( array( 'foo' => 'bar', 'baz' => 'foo' ), 'foo=\'bar\'   baz="foo"', 'Several attributes' ),
-                       array( array( 'foo' => 'bar', 'baz' => 'foo' ), 'foo=\'bar\'   baz="foo"', 'Several attributes' ),
-                       array( array( 'foo' => 'bar', 'baz' => 'foo' ), 'foo=\'bar\'   baz="foo"', 'Several attributes' ),
+                       array(
+                               array( 'foo' => 'bar', 'baz' => 'foo' ),
+                               'foo=\'bar\'   baz="foo"',
+                               'Several attributes'
+                       ),
+                       array(
+                               array( 'foo' => 'bar', 'baz' => 'foo' ),
+                               'foo=\'bar\'   baz="foo"',
+                               'Several attributes'
+                       ),
+                       array(
+                               array( 'foo' => 'bar', 'baz' => 'foo' ),
+                               'foo=\'bar\'   baz="foo"',
+                               'Several attributes'
+                       ),
                        array( array( ':foo' => 'bar' ), ':foo=\'bar\'', 'Leading :' ),
                        array( array( '_foo' => 'bar' ), '_foo=\'bar\'', 'Leading _' ),
                        array( array( 'foo' => 'bar' ), 'Foo=\'bar\'', 'Leading capital' ),
@@ -203,9 +219,21 @@ class SanitizerTest extends MediaWikiTestCase {
                        array( array(), 'foo$=baz', 'Symbols are not allowed' ),
                        array( array(), 'foo@=baz', 'Symbols are not allowed' ),
                        array( array(), 'foo~=baz', 'Symbols are not allowed' ),
-                       array( array( 'foo' => '1[#^`*%w/(' ), 'foo=1[#^`*%w/(', 'All kind of characters are allowed as values' ),
-                       array( array( 'foo' => '1[#^`*%\'w/(' ), 'foo="1[#^`*%\'w/("', 'Double quotes are allowed if quoted by single quotes' ),
-                       array( array( 'foo' => '1[#^`*%"w/(' ), 'foo=\'1[#^`*%"w/(\'', 'Single quotes are allowed if quoted by double quotes' ),
+                       array(
+                               array( 'foo' => '1[#^`*%w/(' ),
+                               'foo=1[#^`*%w/(',
+                               'All kind of characters are allowed as values'
+                       ),
+                       array(
+                               array( 'foo' => '1[#^`*%\'w/(' ),
+                               'foo="1[#^`*%\'w/("',
+                               'Double quotes are allowed if quoted by single quotes'
+                       ),
+                       array(
+                               array( 'foo' => '1[#^`*%"w/(' ),
+                               'foo=\'1[#^`*%"w/(\'',
+                               'Single quotes are allowed if quoted by double quotes'
+                       ),
                        array( array( 'foo' => '&"' ), 'foo=&amp;&quot;', 'Special chars can be provided as entities' ),
                        array( array( 'foo' => '&foobar;' ), 'foo=&foobar;', 'Entity-like items are accepted' ),
                );
@@ -266,15 +294,29 @@ class SanitizerTest extends MediaWikiTestCase {
                                'Remove anything after a comment-start token' ),
                        array( '', "\\2f\\2a unifinished comment'",
                                'Remove anything after a backslash-escaped comment-start token' ),
-                       array( '/* insecure input */', 'filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'asdf.png\',sizingMethod=\'scale\');' ),
-                       array( '/* insecure input */', '-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'asdf.png\',sizingMethod=\'scale\')";' ),
+                       array(
+                               '/* insecure input */',
+                               'filter: progid:DXImageTransform.Microsoft.AlphaImageLoader'
+                                       . '(src=\'asdf.png\',sizingMethod=\'scale\');'
+                       ),
+                       array(
+                               '/* insecure input */',
+                               '-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader'
+                                       . '(src=\'asdf.png\',sizingMethod=\'scale\')";'
+                       ),
                        array( '/* insecure input */', 'width: expression(1+1);' ),
                        array( '/* insecure input */', 'background-image: image(asdf.png);' ),
                        array( '/* insecure input */', 'background-image: -webkit-image(asdf.png);' ),
                        array( '/* insecure input */', 'background-image: -moz-image(asdf.png);' ),
                        array( '/* insecure input */', 'background-image: image-set("asdf.png" 1x, "asdf.png" 2x);' ),
-                       array( '/* insecure input */', 'background-image: -webkit-image-set("asdf.png" 1x, "asdf.png" 2x);' ),
-                       array( '/* insecure input */', 'background-image: -moz-image-set("asdf.png" 1x, "asdf.png" 2x);' ),
+                       array(
+                               '/* insecure input */',
+                               'background-image: -webkit-image-set("asdf.png" 1x, "asdf.png" 2x);'
+                       ),
+                       array(
+                               '/* insecure input */',
+                               'background-image: -moz-image-set("asdf.png" 1x, "asdf.png" 2x);'
+                       ),
                );
        }
 
@@ -284,7 +326,12 @@ class SanitizerTest extends MediaWikiTestCase {
        public static function provideAttributeSupport() {
                /** array( <attributes>, <expected>, <message> ) */
                return array(
-                       array( 'div', ' role="presentation"', ' role="presentation"', 'Support for WAI-ARIA\'s role="presentation".' ),
+                       array(
+                               'div',
+                               ' role="presentation"',
+                               ' role="presentation"',
+                               'Support for WAI-ARIA\'s role="presentation".'
+                       ),
                        array( 'div', ' role="main"', '', "Other WAI-ARIA roles are currently not supported." ),
                );
        }
index 572740f..6547c87 100644 (file)
@@ -323,16 +323,41 @@ class SiteConfigurationTest extends MediaWikiTestCase {
                        'fallback' => 'tag',
                        'params' => 'en wiki enwiki',
                        'global' => array( 'enwiki' => 'enwiki' ) + $GLOBALS['global'],
-                       'merge' => array( 'enwiki' => 'enwiki', 'tag' => 'tag', 'wiki' => 'wiki', 'default' => 'default' ),
+                       'merge' => array(
+                               'enwiki' => 'enwiki',
+                               'tag' => 'tag',
+                               'wiki' => 'wiki',
+                               'default' => 'default'
+                       ),
                );
                $this->assertEquals( $getall, $this->mConf->getAll( 'enwiki' ), 'getAll()' );
 
                $this->mConf->extractAllGlobals( 'enwiki', 'wiki' );
 
-               $this->assertEquals( $getall['simple'], $GLOBALS['simple'], 'extractAllGlobals(): simple setting' );
-               $this->assertEquals( $getall['fallback'], $GLOBALS['fallback'], 'extractAllGlobals(): fallback setting' );
-               $this->assertEquals( $getall['params'], $GLOBALS['params'], 'extractAllGlobals(): parameter replacement' );
-               $this->assertEquals( $getall['global'], $GLOBALS['global'], 'extractAllGlobals(): merging with global' );
-               $this->assertEquals( $getall['merge'], $GLOBALS['merge'], 'extractAllGlobals(): merging setting' );
+               $this->assertEquals(
+                       $getall['simple'],
+                       $GLOBALS['simple'],
+                       'extractAllGlobals(): simple setting'
+               );
+               $this->assertEquals(
+                       $getall['fallback'],
+                       $GLOBALS['fallback'],
+                       'extractAllGlobals(): fallback setting'
+               );
+               $this->assertEquals(
+                       $getall['params'],
+                       $GLOBALS['params'],
+                       'extractAllGlobals(): parameter replacement'
+               );
+               $this->assertEquals(
+                       $getall['global'],
+                       $GLOBALS['global'],
+                       'extractAllGlobals(): merging with global'
+               );
+               $this->assertEquals(
+                       $getall['merge'],
+                       $GLOBALS['merge'],
+                       'extractAllGlobals(): merging setting'
+               );
        }
 }
index 8f54714..baa995d 100644 (file)
@@ -10,7 +10,6 @@
  */
 
 class SkinTemplateTest extends MediaWikiTestCase {
-
        /**
         * @dataProvider makeListItemProvider
         */
@@ -29,7 +28,13 @@ class SkinTemplateTest extends MediaWikiTestCase {
                        array(
                                '<li class="class" title="itemtitle"><a href="url" title="title">text</a></li>',
                                '',
-                               array( 'class' => 'class', 'itemtitle' => 'itemtitle', 'href' => 'url', 'title' => 'title', 'text' => 'text' ),
+                               array(
+                                       'class' => 'class',
+                                       'itemtitle' => 'itemtitle',
+                                       'href' => 'url',
+                                       'title' => 'title',
+                                       'text' => 'text'
+                               ),
                                array(),
                                'Test makteListItem with normal values'
                        )