From d5df012a1368b7345f5ce043ca0bb961180312a3 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 24 Apr 2014 14:35:05 +0200 Subject: [PATCH] Pass phpcs-strict on some test files (3/x) Change-Id: I44172b512cd9b6c43806dad697e449bf06897305 --- tests/phpunit/includes/LocalFileTest.php | 71 +++++++++++++++---- tests/phpunit/includes/MessageTest.php | 53 +++++++++++--- tests/phpunit/includes/PathRouterTest.php | 2 + tests/phpunit/includes/RequestContextTest.php | 29 ++++++-- .../phpunit/includes/RevisionStorageTest.php | 70 +++++++++++++----- ...evisionStorageTestContentHandlerUseDB.php} | 17 +++-- tests/phpunit/includes/RevisionTest.php | 45 +++++++++--- tests/phpunit/includes/SampleTest.php | 10 ++- tests/phpunit/includes/SanitizerTest.php | 71 +++++++++++++++---- .../includes/SiteConfigurationTest.php | 37 ++++++++-- tests/phpunit/includes/SkinTemplateTest.php | 9 ++- 11 files changed, 332 insertions(+), 82 deletions(-) rename tests/phpunit/includes/{RevisionStorageTest_ContentHandlerUseDB.php => RevisionStorageTestContentHandlerUseDB.php} (85%) diff --git a/tests/phpunit/includes/LocalFileTest.php b/tests/phpunit/includes/LocalFileTest.php index d210ce51b5..5c5052e485 100644 --- a/tests/phpunit/includes/LocalFileTest.php +++ b/tests/phpunit/includes/LocalFileTest.php @@ -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' + ); } } diff --git a/tests/phpunit/includes/MessageTest.php b/tests/phpunit/includes/MessageTest.php index 25b0805df6..7db985bd5a 100644 --- a/tests/phpunit/includes/MessageTest.php +++ b/tests/phpunit/includes/MessageTest.php @@ -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' )" ); } diff --git a/tests/phpunit/includes/PathRouterTest.php b/tests/phpunit/includes/PathRouterTest.php index e60dc5484c..0d7826871f 100644 --- a/tests/phpunit/includes/PathRouterTest.php +++ b/tests/phpunit/includes/PathRouterTest.php @@ -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 } /** diff --git a/tests/phpunit/includes/RequestContextTest.php b/tests/phpunit/includes/RequestContextTest.php index 1776b5d5ef..f595d2dc64 100644 --- a/tests/phpunit/includes/RequestContextTest.php +++ b/tests/phpunit/includes/RequestContextTest.php @@ -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 diff --git a/tests/phpunit/includes/RevisionStorageTest.php b/tests/phpunit/includes/RevisionStorageTest.php index e69660edea..9a429bcb37 100644 --- a/tests/phpunit/includes/RevisionStorageTest.php +++ b/tests/phpunit/includes/RevisionStorageTest.php @@ -11,11 +11,10 @@ * ^--- 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/RevisionStorageTest_ContentHandlerUseDB.php b/tests/phpunit/includes/RevisionStorageTestContentHandlerUseDB.php similarity index 85% rename from tests/phpunit/includes/RevisionStorageTest_ContentHandlerUseDB.php rename to tests/phpunit/includes/RevisionStorageTestContentHandlerUseDB.php index f830e3677d..d5e47c8235 100644 --- a/tests/phpunit/includes/RevisionStorageTest_ContentHandlerUseDB.php +++ b/tests/phpunit/includes/RevisionStorageTestContentHandlerUseDB.php @@ -5,7 +5,7 @@ * @group Database * ^--- important, causes temporary tables to be used instead of the real database */ -class RevisionTest_ContentHandlerUseDB extends RevisionStorageTest { +class RevisionTestContentHandlerUseDB extends RevisionStorageTest { protected function setUp() { $this->setMwGlobals( 'wgContentHandlerUseDB', false ); @@ -35,11 +35,20 @@ class RevisionTest_ContentHandlerUseDB extends RevisionStorageTest { $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' ); - $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' ); + $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' + ); } /** diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index 48a4017ad7..4623b38341 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -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 diff --git a/tests/phpunit/includes/SampleTest.php b/tests/phpunit/includes/SampleTest.php index 7e81fab51f..758c2e277b 100644 --- a/tests/phpunit/includes/SampleTest.php +++ b/tests/phpunit/includes/SampleTest.php @@ -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() ); diff --git a/tests/phpunit/includes/SanitizerTest.php b/tests/phpunit/includes/SanitizerTest.php index f5551edf3e..50c1e50980 100644 --- a/tests/phpunit/includes/SanitizerTest.php +++ b/tests/phpunit/includes/SanitizerTest.php @@ -84,7 +84,11 @@ class SanitizerTest extends MediaWikiTestCase { * @covers Sanitizer::decodeCharReferences */ public function testInvalidNumberedEntities() { - $this->assertEquals( UTF8_REPLACEMENT, Sanitizer::decodeCharReferences( "�" ), 'Invalid numbered entity' ); + $this->assertEquals( + UTF8_REPLACEMENT, + Sanitizer::decodeCharReferences( "�" ), + '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=&"', '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( , , ) */ 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." ), ); } diff --git a/tests/phpunit/includes/SiteConfigurationTest.php b/tests/phpunit/includes/SiteConfigurationTest.php index 572740f48b..6547c873a0 100644 --- a/tests/phpunit/includes/SiteConfigurationTest.php +++ b/tests/phpunit/includes/SiteConfigurationTest.php @@ -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' + ); } } diff --git a/tests/phpunit/includes/SkinTemplateTest.php b/tests/phpunit/includes/SkinTemplateTest.php index 8f54714908..baa995d4e6 100644 --- a/tests/phpunit/includes/SkinTemplateTest.php +++ b/tests/phpunit/includes/SkinTemplateTest.php @@ -10,7 +10,6 @@ */ class SkinTemplateTest extends MediaWikiTestCase { - /** * @dataProvider makeListItemProvider */ @@ -29,7 +28,13 @@ class SkinTemplateTest extends MediaWikiTestCase { array( '
  • text
  • ', '', - 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' ) -- 2.20.1