* @covers ChangesListSpecialPage
*/
class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase {
- public function setUp() {
- parent::setUp();
- $this->setMwGlobals( [
- 'wgStructuredChangeFiltersShowPreference' => true,
- ] );
- }
-
protected function getPage() {
$mock = $this->getMockBuilder( ChangesListSpecialPage::class )
->setConstructorArgs(
}
public function testRcHidemyselfFilter() {
- $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_WRITE_BOTH );
+ $this->setMwGlobals(
+ 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
+ );
$this->overrideMwServices();
$user = $this->getTestUser()->getUser();
$user->getActorId( wfGetDB( DB_MASTER ) );
$this->assertConditions(
[ # expected
- "NOT((rc_actor = '{$user->getActorId()}') OR "
- . "(rc_actor = '0' AND rc_user = '{$user->getId()}'))",
+ "NOT((rc_user = '{$user->getId()}'))",
],
[
'hidemyself' => 1,
$id = $user->getActorId( wfGetDB( DB_MASTER ) );
$this->assertConditions(
[ # expected
- "NOT((rc_actor = '$id') OR (rc_actor = '0' AND rc_user_text = '10.11.12.13'))",
+ "NOT((rc_user_text = '10.11.12.13'))",
],
[
'hidemyself' => 1,
}
public function testRcHidebyothersFilter() {
- $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_WRITE_BOTH );
+ $this->setMwGlobals(
+ 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
+ );
$this->overrideMwServices();
$user = $this->getTestUser()->getUser();
$user->getActorId( wfGetDB( DB_MASTER ) );
$this->assertConditions(
[ # expected
- "(rc_actor = '{$user->getActorId()}') OR "
- . "(rc_actor = '0' AND rc_user_text = '{$user->getName()}')",
+ "(rc_user_text = '{$user->getName()}')",
],
[
'hidebyothers' => 1,
$id = $user->getActorId( wfGetDB( DB_MASTER ) );
$this->assertConditions(
[ # expected
- "(rc_actor = '$id') OR (rc_actor = '0' AND rc_user_text = '10.11.12.13')",
+ "(rc_user_text = '10.11.12.13')",
],
[
'hidebyothers' => 1,
$user = $this->getTestSysop()->getUser();
$this->assertConditions(
[ # expected
- 'rc_patrolled = 0',
+ 'rc_patrolled' => 0,
],
[
'hidepatrolled' => 1,
$user = $this->getTestSysop()->getUser();
$this->assertConditions(
[ # expected
- 'rc_patrolled != 0',
+ 'rc_patrolled' => [ 1, 2 ],
],
[
'hideunpatrolled' => 1,
);
}
+ 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
}
public function testFilterUserExpLevelAllExperienceLevels() {
- $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_WRITE_BOTH );
+ $this->setMwGlobals(
+ 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
+ );
$this->overrideMwServices();
$this->assertConditions(
[
# expected
- 'COALESCE( actor_rc_user.actor_user, rc_user ) != 0',
+ 'rc_user != 0',
],
[
'userExpLevel' => 'newcomer;learner;experienced',
}
public function testFilterUserExpLevelRegistrered() {
- $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_WRITE_BOTH );
+ $this->setMwGlobals(
+ 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
+ );
$this->overrideMwServices();
$this->assertConditions(
[
# expected
- 'COALESCE( actor_rc_user.actor_user, rc_user ) != 0',
+ 'rc_user != 0',
],
[
'userExpLevel' => 'registered',
}
public function testFilterUserExpLevelUnregistrered() {
- $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_WRITE_BOTH );
+ $this->setMwGlobals(
+ 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
+ );
$this->overrideMwServices();
$this->assertConditions(
[
# expected
- 'COALESCE( actor_rc_user.actor_user, rc_user ) = 0',
+ 'rc_user = 0',
],
[
'userExpLevel' => 'unregistered',
}
public function testFilterUserExpLevelRegistreredOrLearner() {
- $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_WRITE_BOTH );
+ $this->setMwGlobals(
+ 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
+ );
$this->overrideMwServices();
$this->assertConditions(
[
# expected
- 'COALESCE( actor_rc_user.actor_user, rc_user ) != 0',
+ 'rc_user != 0',
],
[
'userExpLevel' => 'registered;learner',
}
public function testFilterUserExpLevelUnregistreredOrExperienced() {
- $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_WRITE_BOTH );
+ $this->setMwGlobals(
+ 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
+ );
$this->overrideMwServices();
$conds = $this->buildQuery( [ 'userExpLevel' => 'unregistered;experienced' ] );
$this->assertRegExp(
- '/\(COALESCE\( actor_rc_user.actor_user, rc_user \) = 0\) OR '
+ '/\(rc_user = 0\) OR '
. '\(\(user_editcount >= 500\) AND \(user_registration <= \'[^\']+\'\)\)/',
reset( $conds ),
"rc conditions: userExpLevel=unregistered;experienced"
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 = [];
[ 'hideanons' => 1, 'hideliu' => 1, 'hidebots' => 1 ],
true,
[ 'userExpLevel' => 'unregistered', 'hidebots' => 1, ],
+ true,
],
[
[ 'hideanons' => 1, 'hideliu' => 1, 'hidebots' => 0 ],
true,
[ 'hidebots' => 0, 'hidehumans' => 1 ],
+ true,
],
[
[ 'hideanons' => 1 ],
true,
- [ 'userExpLevel' => 'registered' ]
+ [ 'userExpLevel' => 'registered' ],
+ true,
],
[
[ 'hideliu' => 1 ],
true,
- [ 'userExpLevel' => 'unregistered' ]
+ [ 'userExpLevel' => 'unregistered' ],
+ true,
],
[
[ 'hideanons' => 1, 'hidebots' => 1 ],
true,
- [ 'userExpLevel' => 'registered', 'hidebots' => 1 ]
+ [ 'userExpLevel' => 'registered', 'hidebots' => 1 ],
+ true,
],
[
[ 'hideliu' => 1, 'hidebots' => 0 ],
true,
- [ 'userExpLevel' => 'unregistered', 'hidebots' => 0 ]
+ [ 'userExpLevel' => 'unregistered', 'hidebots' => 0 ],
+ true,
],
[
[ 'hidemyself' => 1, 'hidebyothers' => 1 ],
true,
[],
+ true,
],
[
[ 'hidebots' => 1, 'hidehumans' => 1 ],
true,
[],
+ true,
],
[
[ 'hidepatrolled' => 1, 'hideunpatrolled' => 1 ],
true,
[],
+ true,
],
[
[ 'hideminor' => 1, 'hidemajor' => 1 ],
true,
[],
+ true,
],
[
// changeType
[ 'hidepageedits' => 1, 'hidenewpages' => 1, 'hidecategorization' => 1, 'hidelog' => 1, ],
true,
[],
+ true,
],
];
}