diff options
author | Daimona Eaytoy <daimona.wiki@gmail.com> | 2022-10-07 19:03:35 +0200 |
---|---|---|
committer | James D. Forrester <jforrester@wikimedia.org> | 2022-10-07 14:13:16 -0400 |
commit | ee672592d8b18d2c76f225c875509307380b7925 (patch) | |
tree | 2c7c491680f0bf46889244c2961d2b7281496331 /tests/phpunit/includes/changes | |
parent | bb2fc938e529c75a6a8226b473f5a1cf23dbb56c (diff) | |
download | mediawikicore-ee672592d8b18d2c76f225c875509307380b7925.tar.gz mediawikicore-ee672592d8b18d2c76f225c875509307380b7925.zip |
tests: Replace assertRegExp with assertMatchesRegularExpression
And also assertNotRegExp -> assertDoesNotMatchRegularExpression. The
methods were renamed in PHPUnit 9.
Done automatically with:
grep -rl assertRegExp tests/ | xargs sed -r -i "s/>assertRegExp\(/>assertMatchesRegularExpression\(/"
grep -rl assertNotRegExp tests/ | xargs sed -r -i "s/>assertNotRegExp\(/>assertDoesNotMatchRegularExpression\(/"
Split out from Ifdba0f9e98eb6bce4590b7eb73170c51a697d7c6 so that it
remains smaller and easier to review.
Also make a test use MediaWikiUnitTestCase (it's already in the unit/
dir) so that it can access the forward-compat method.
Bug: T243600
Change-Id: Ifa279d5f201d7abeebece292141ebface8278046
Diffstat (limited to 'tests/phpunit/includes/changes')
3 files changed, 24 insertions, 24 deletions
diff --git a/tests/phpunit/includes/changes/EnhancedChangesListTest.php b/tests/phpunit/includes/changes/EnhancedChangesListTest.php index f2256ca8f351..3a1813f4fb9b 100644 --- a/tests/phpunit/includes/changes/EnhancedChangesListTest.php +++ b/tests/phpunit/includes/changes/EnhancedChangesListTest.php @@ -116,10 +116,10 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase { $html = $enhancedChangesList->endRecentChangesList(); - $this->assertRegExp( '/Hello world prefix/', $html ); + $this->assertMatchesRegularExpression( '/Hello world prefix/', $html ); // Test EnhancedChangesListModifyLineData hook was run - $this->assertRegExp( '/This is a minor edit/', $html ); + $this->assertMatchesRegularExpression( '/This is a minor edit/', $html ); // Two separate lines $enhancedChangesList->beginRecentChangesList(); @@ -132,7 +132,7 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase { $html = $enhancedChangesList->endRecentChangesList(); // Test EnhancedChangesListModifyBlockLineData hook was run - $this->assertRegExp( '/This edit was performed by a bot/', $html ); + $this->assertMatchesRegularExpression( '/This edit was performed by a bot/', $html ); preg_match_all( '/Hello world prefix/', $html, $matches ); $this->assertCount( 2, $matches[0] ); @@ -163,7 +163,7 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase { $enhancedChangesList->recentChangesLine( $recentChange, false ); $html = $enhancedChangesList->endRecentChangesList(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/data-mw-revid="5" data-mw-ts="20131103092153" class="[^"]*mw-enhanced-rc[^"]*"/', $html ); diff --git a/tests/phpunit/includes/changes/OldChangesListTest.php b/tests/phpunit/includes/changes/OldChangesListTest.php index cd9ae19899c7..ef65c9340185 100644 --- a/tests/phpunit/includes/changes/OldChangesListTest.php +++ b/tests/phpunit/includes/changes/OldChangesListTest.php @@ -37,7 +37,7 @@ class OldChangesListTest extends MediaWikiLangTestCase { $line = $oldChangesList->recentChangesLine( $recentChange, false, $linenumber ); - $this->assertRegExp( $expected, $line, $message ); + $this->assertMatchesRegularExpression( $expected, $line, $message ); } public function recentChangesLine_CssForLineNumberProvider() { @@ -53,7 +53,7 @@ class OldChangesListTest extends MediaWikiLangTestCase { $line = $oldChangesList->recentChangesLine( $recentChange, false, 1 ); - $this->assertRegExp( '/mw-changeslist-line-not-watched/', $line ); + $this->assertMatchesRegularExpression( '/mw-changeslist-line-not-watched/', $line ); } public function testRecentChangesLine_WatchedCssClass() { @@ -62,7 +62,7 @@ class OldChangesListTest extends MediaWikiLangTestCase { $line = $oldChangesList->recentChangesLine( $recentChange, true, 1 ); - $this->assertRegExp( '/mw-changeslist-line-watched/', $line ); + $this->assertMatchesRegularExpression( '/mw-changeslist-line-watched/', $line ); } public function testRecentChangesLine_LogTitle() { @@ -71,9 +71,9 @@ class OldChangesListTest extends MediaWikiLangTestCase { $line = $oldChangesList->recentChangesLine( $recentChange, false, 1 ); - $this->assertRegExp( '/href="\/wiki\/Special:Log\/delete/', $line, 'link has href attribute' ); - $this->assertRegExp( '/title="Special:Log\/delete/', $line, 'link has title attribute' ); - $this->assertRegExp( "/dellogpage/", $line, 'link text' ); + $this->assertMatchesRegularExpression( '/href="\/wiki\/Special:Log\/delete/', $line, 'link has href attribute' ); + $this->assertMatchesRegularExpression( '/title="Special:Log\/delete/', $line, 'link has title attribute' ); + $this->assertMatchesRegularExpression( "/dellogpage/", $line, 'link text' ); } public function testRecentChangesLine_DiffHistLinks() { @@ -82,13 +82,13 @@ class OldChangesListTest extends MediaWikiLangTestCase { $line = $oldChangesList->recentChangesLine( $recentChange, false, 1 ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/title=Cat&curid=20131103212153&diff=5&oldid=191/', $line, 'assert diff link' ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/title=Cat&curid=20131103212153&action=history"/', $line, 'assert history link' @@ -131,11 +131,11 @@ class OldChangesListTest extends MediaWikiLangTestCase { '/<div>Additional change line </div>/', $line ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/<li data-mw-revid="\d+" data-mw-ts="\d+" class="[\w\s-]*mw-tag-vandalism[\w\s-]*">/', $line ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/<li data-mw-revid="\d+" data-mw-ts="\d+" class="[\w\s-]*mw-tag-newbie[\w\s-]*">/', $line ); @@ -148,7 +148,7 @@ class OldChangesListTest extends MediaWikiLangTestCase { $recentChange->numberofWatchingusers = 100; $line = $oldChangesList->recentChangesLine( $recentChange, false, 1 ); - $this->assertRegExp( "/(number-of-watching-users-for-recent-changes: 100)/", $line ); + $this->assertMatchesRegularExpression( "/(number-of-watching-users-for-recent-changes: 100)/", $line ); } public function testRecentChangesLine_watchlistCssClass() { @@ -157,7 +157,7 @@ class OldChangesListTest extends MediaWikiLangTestCase { $recentChange = $this->getEditChange(); $line = $oldChangesList->recentChangesLine( $recentChange, false, 1 ); - $this->assertRegExp( "/watchlist-0-Cat/", $line ); + $this->assertMatchesRegularExpression( "/watchlist-0-Cat/", $line ); } public function testRecentChangesLine_dataAttribute() { @@ -166,11 +166,11 @@ class OldChangesListTest extends MediaWikiLangTestCase { $recentChange = $this->getEditChange(); $line = $oldChangesList->recentChangesLine( $recentChange, false, 1 ); - $this->assertRegExp( '/data-target-page=\"Cat\"/', $line ); + $this->assertMatchesRegularExpression( '/data-target-page=\"Cat\"/', $line ); $recentChange = $this->getLogChange( 'delete', 'delete' ); $line = $oldChangesList->recentChangesLine( $recentChange, false, 1 ); - $this->assertRegExp( '/data-target-page="Abc"/', $line ); + $this->assertMatchesRegularExpression( '/data-target-page="Abc"/', $line ); } public function testRecentChangesLine_prefix() { @@ -191,7 +191,7 @@ class OldChangesListTest extends MediaWikiLangTestCase { return 'I am a prefix'; } ); $line = $oldChangesList->recentChangesLine( $recentChange ); - $this->assertRegExp( "/I am a prefix/", $line ); + $this->assertMatchesRegularExpression( "/I am a prefix/", $line ); } private function getNewBotEditChange() { diff --git a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php index 091b2948d4f9..ea68d1cb7e69 100644 --- a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php +++ b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php @@ -141,21 +141,21 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase { private function assertUserLinks( $user, $cacheEntry ) { $this->assertValidHTML( $cacheEntry->userlink ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#^<a .*class="new mw-userlink".*><bdi>' . $user . '</bdi></a>#', $cacheEntry->userlink, 'verify user link' ); $this->assertValidHTML( $cacheEntry->usertalklink ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#^ <span class="mw-usertoollinks mw-changeslist-links">.*<span><a .+>talk</a></span>.*</span>#', $cacheEntry->usertalklink, 'verify user talk link' ); $this->assertValidHTML( $cacheEntry->usertalklink ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#^ <span class="mw-usertoollinks mw-changeslist-links">.*<span><a .+>' . 'contribs</a></span>.*</span>$#', $cacheEntry->usertalklink, @@ -192,7 +192,7 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase { } private function assertQueryLink( $content, $params, $link ) { - $this->assertRegExp( + $this->assertMatchesRegularExpression( "#^<a .+>$content</a>$#", $link, 'verify query link element' @@ -200,7 +200,7 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase { $this->assertValidHTML( $link ); foreach ( $params as $key => $value ) { - $this->assertRegExp( '/' . $key . '=' . $value . '/', $link, "verify $key link params" ); + $this->assertMatchesRegularExpression( '/' . $key . '=' . $value . '/', $link, "verify $key link params" ); } } |