X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fspecialpage%2FChangesListSpecialPageTest.php;h=19a1875d58eba8993fb7f8fb60b2dd4766f04279;hb=4df0c71911500466a6330b8fe29c623ef5b51e41;hp=d612b538d0917b08c58a94f51b650034d3c80617;hpb=87f40138c64ddccb6dc6d54531cea02af40ef0f3;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php b/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php index d612b538d0..19a1875d58 100644 --- a/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php +++ b/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php @@ -105,9 +105,14 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase } private static function normalizeCondition( $conds ) { + $dbr = wfGetDB( DB_REPLICA ); $normalized = array_map( - function ( $k, $v ) { - return is_numeric( $k ) ? $v : "$k = $v"; + function ( $k, $v ) use ( $dbr ) { + if ( is_array( $v ) ) { + sort( $v ); + } + // (Ab)use makeList() to format only this entry + return $dbr->makeList( [ $k => $v ], Database::LIST_AND ); }, array_keys( $conds ), $conds @@ -116,9 +121,9 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase return $normalized; } - /** return false if condition begin with 'rc_timestamp ' */ + /** return false if condition begins with 'rc_timestamp ' */ private static function filterOutRcTimestampCondition( $var ) { - return ( false === strpos( $var, 'rc_timestamp ' ) ); + return ( is_array( $var ) || false === strpos( $var, 'rc_timestamp ' ) ); } public function testRcNsFilter() { @@ -342,7 +347,7 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase $user = $this->getTestSysop()->getUser(); $this->assertConditions( [ # expected - "rc_patrolled = 0", + 'rc_patrolled' => 0, ], [ 'hidepatrolled' => 1, @@ -356,7 +361,7 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase $user = $this->getTestSysop()->getUser(); $this->assertConditions( [ # expected - "rc_patrolled != 0", + 'rc_patrolled' => [ 1, 2 ], ], [ 'hideunpatrolled' => 1, @@ -366,6 +371,30 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase ); } + public function testRcReviewStatusFilter() { + $user = $this->getTestSysop()->getUser(); + $this->assertConditions( + [ #expected + 'rc_patrolled' => 1, + ], + [ + 'reviewStatus' => 'manual' + ], + "rc conditions: reviewStatus=manual", + $user + ); + $this->assertConditions( + [ #expected + 'rc_patrolled' => [ 0, 2 ], + ], + [ + 'reviewStatus' => 'unpatrolled;auto' + ], + "rc conditions: reviewStatus=unpatrolled;auto", + $user + ); + } + public function testRcHideminorFilter() { $this->assertConditions( [ # expected @@ -644,43 +673,6 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase return $now - $days * $secondsPerDay; } - public function testGetFilterGroupDefinitionFromLegacyCustomFilters() { - $customFilters = [ - 'hidefoo' => [ - 'msg' => 'showhidefoo', - 'default' => true, - ], - - 'hidebar' => [ - 'msg' => 'showhidebar', - 'default' => false, - ], - ]; - - $this->assertEquals( - [ - 'name' => 'unstructured', - 'class' => ChangesListBooleanFilterGroup::class, - 'priority' => -1, - 'filters' => [ - [ - 'name' => 'hidefoo', - 'showHide' => 'showhidefoo', - 'default' => true, - ], - [ - 'name' => 'hidebar', - 'showHide' => 'showhidebar', - 'default' => false, - ] - ], - ], - $this->changesListSpecialPage->getFilterGroupDefinitionFromLegacyCustomFilters( - $customFilters - ) - ); - } - public function testGetStructuredFilterJsData() { $this->changesListSpecialPage->filterGroups = [];