jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/375440 )
Change subject: tests: Return a TestingAccessWrapper always ...................................................................... tests: Return a TestingAccessWrapper always Instead of reapeating the exact same code in every test, just do it once in the getMockPage() function. Change-Id: I636432061c08817bb4d833c5bc0ccf241da5cb33 --- M tests/phpunit/includes/TwoColConflictPageTest.php 1 file changed, 12 insertions(+), 15 deletions(-) Approvals: Addshore: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/phpunit/includes/TwoColConflictPageTest.php b/tests/phpunit/includes/TwoColConflictPageTest.php index f055579..6f9af84 100644 --- a/tests/phpunit/includes/TwoColConflictPageTest.php +++ b/tests/phpunit/includes/TwoColConflictPageTest.php @@ -12,7 +12,7 @@ * @covers TwoColConflictPageTest::getCollapsedText */ public function testGetCollapsedText_returnFalseWhenInLimit() { - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $this->getMockPage() ); + $twoColConflictPageMock = $this->getMockPage(); $this->assertFalse( $twoColConflictPageMock->getCollapsedText( 'One Two Three.', 14 ) ); @@ -26,7 +26,6 @@ */ public function testGetCollapsedText_returnFalseWhenWhenOverLimitWithWhitespaces() { $twoColConflictPageMock = $this->getMockPageWithContext(); - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $twoColConflictPageMock ); $this->assertFalse( $twoColConflictPageMock->getCollapsedText( "One Two Three.\n \n", 14 ) ); @@ -40,7 +39,6 @@ */ public function testGetCollapsedText_cutWhenSingleLineOverLimit() { $twoColConflictPageMock = $this->getMockPageWithContext(); - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $twoColConflictPageMock ); $this->assertEquals( '<span class="mw-twocolconflict-diffchange-fadeout-end">One</span> ' . '<span class="mw-twocolconflict-diffchange-fadeout-start">even.</span>', @@ -53,7 +51,6 @@ */ public function testGetCollapsedText_returnFalseWhenTwoLinesInLimit() { $twoColConflictPageMock = $this->getMockPageWithContext(); - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $twoColConflictPageMock ); $this->assertFalse( $twoColConflictPageMock->getCollapsedText( "One Two\nThree Four.", 25 ) ); @@ -64,7 +61,6 @@ */ public function testGetCollapsedText_cutWhenTwoLinesOverLimit() { $twoColConflictPageMock = $this->getMockPageWithContext(); - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $twoColConflictPageMock ); $this->assertEquals( "<span class=\"mw-twocolconflict-diffchange-fadeout-end\">One</span>\n" . "<span class=\"mw-twocolconflict-diffchange-fadeout-start\">Four.</span>", @@ -77,7 +73,6 @@ */ public function testGetCollapsedText_cutWhenMultipleLinesInLimit() { $twoColConflictPageMock = $this->getMockPageWithContext(); - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $twoColConflictPageMock ); $this->assertEquals( "<span class=\"mw-twocolconflict-diffchange-fadeout-end\">One Two</span>\n" . "<span class=\"mw-twocolconflict-diffchange-fadeout-start\">Six Seven.</span>", @@ -89,7 +84,7 @@ * @covers TwoColConflictPageTest::trimStringToFullWord */ public function testTrimStringToFullWord_noCutWhenInLimit() { - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $this->getMockPage() ); + $twoColConflictPageMock = $this->getMockPage(); $this->assertEquals( 'One Two Three.', $twoColConflictPageMock->trimStringToFullWord( 'One Two Three.', 14 ) @@ -104,7 +99,7 @@ * @covers TwoColConflictPageTest::trimStringToFullWord */ public function testTrimStringToFullWord_trimWhiteSpaceAtEndOfResult() { - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $this->getMockPage() ); + $twoColConflictPageMock = $this->getMockPage(); $this->assertEquals( 'One Two', $twoColConflictPageMock->trimStringToFullWord( 'One Two Three.', 8, true ) @@ -115,7 +110,7 @@ * @covers TwoColConflictPageTest::trimStringToFullWord */ public function testTrimStringToFullWord_trimWhiteSpaceAtStartOfResult() { - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $this->getMockPage() ); + $twoColConflictPageMock = $this->getMockPage(); $this->assertEquals( 'Three.', $twoColConflictPageMock->trimStringToFullWord( 'One Two. And Three.', 7, false ) @@ -130,7 +125,7 @@ * @covers TwoColConflictPageTest::trimStringToFullWord */ public function testTrimStringToFullWord_atEnd( $input, $maxLength, $result ) { - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $this->getMockPage() ); + $twoColConflictPageMock = $this->getMockPage(); self::assertEquals( $result, $twoColConflictPageMock->trimStringToFullWord( $input, $maxLength, true ) @@ -165,7 +160,7 @@ * @covers TwoColConflictPageTest::trimStringToFullWord */ public function testTrimStringToFullWord_atStart( $input, $maxLength, $result ) { - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $this->getMockPage() ); + $twoColConflictPageMock = $this->getMockPage(); self::assertEquals( $result, $twoColConflictPageMock->trimStringToFullWord( $input, $maxLength, false ) @@ -200,7 +195,7 @@ * @covers TwoColConflictPageTest::trimWhiteSpaces */ public function testTrimWhiteSpaces( $input, $trimAtEnd, $result ) { - $twoColConflictPageMock = TestingAccessWrapper::newFromObject( $this->getMockPage() ); + $twoColConflictPageMock = $this->getMockPage(); self::assertEquals( $result, $twoColConflictPageMock->trimWhiteSpaces( $input, $trimAtEnd ) @@ -231,9 +226,11 @@ * @return TwoColConflictPage */ private function getMockPage() { - return $this->getMockBuilder( TwoColConflictPage::class ) - ->disableOriginalConstructor() - ->getMock(); + return TestingAccessWrapper::newFromObject( + $this->getMockBuilder( TwoColConflictPage::class ) + ->disableOriginalConstructor() + ->getMock() + ); } /** -- To view, visit https://gerrit.wikimedia.org/r/375440 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I636432061c08817bb4d833c5bc0ccf241da5cb33 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TwoColConflict Gerrit-Branch: master Gerrit-Owner: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Andrew-WMDE <andrew.kos...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: WMDE-Fisch <christoph.jau...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits