protected function setUp() {
parent::setUp();
+ $this->tablesUsed = array_merge(
+ $this->tablesUsed,
+ [ 'change_tag', 'change_tag_def', 'logging' ]
+ );
$this->mUser = $this->getMutableTestUser()->getUser();
}
}
public function testBlockWithTag() {
+ $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
ChangeTags::defineTag( 'custom tag' );
$this->doBlock( [ 'tags' => 'custom tag' ] );
) );
}
+ public function testBlockWithTagNewBackend() {
+ $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
+ ChangeTags::defineTag( 'custom tag' );
+
+ $this->doBlock( [ 'tags' => 'custom tag' ] );
+
+ $dbw = wfGetDB( DB_MASTER );
+ $this->assertSame( 1, (int)$dbw->selectField(
+ [ 'change_tag', 'logging', 'change_tag_def' ],
+ 'COUNT(*)',
+ [ 'log_type' => 'block', 'ctd_name' => 'custom tag' ],
+ __METHOD__,
+ [],
+ [
+ 'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ],
+ 'change_tag_def' => [ 'INNER JOIN', 'ctd_id = ct_tag_id' ],
+ ]
+ ) );
+ }
+
public function testBlockWithProhibitedTag() {
$this->setExpectedException( ApiUsageException::class,
'You do not have permission to apply change tags along with your changes.' );
* @covers ApiDelete
*/
class ApiDeleteTest extends ApiTestCase {
+
+ protected function setUp() {
+ parent::setUp();
+ $this->tablesUsed = array_merge(
+ $this->tablesUsed,
+ [ 'change_tag', 'change_tag_def', 'logging' ]
+ );
+ }
+
public function testDelete() {
$name = 'Help:' . ucfirst( __FUNCTION__ );
}
public function testDeleteWithTag() {
+ $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
$name = 'Help:' . ucfirst( __FUNCTION__ );
ChangeTags::defineTag( 'custom tag' );
) );
}
+ public function testDeleteWithTagNewBackend() {
+ $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
+ $name = 'Help:' . ucfirst( __FUNCTION__ );
+
+ ChangeTags::defineTag( 'custom tag' );
+
+ $this->editPage( $name, 'Some text' );
+
+ $this->doApiRequestWithToken( [
+ 'action' => 'delete',
+ 'title' => $name,
+ 'tags' => 'custom tag',
+ ] );
+
+ $this->assertFalse( Title::newFromText( $name )->exists() );
+
+ $dbw = wfGetDB( DB_MASTER );
+ $this->assertSame( 'custom tag', $dbw->selectField(
+ [ 'change_tag', 'logging', 'change_tag_def' ],
+ 'ctd_name',
+ [
+ 'log_namespace' => NS_HELP,
+ 'log_title' => ucfirst( __FUNCTION__ ),
+ ],
+ __METHOD__,
+ [],
+ [
+ 'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ],
+ 'change_tag_def' => [ 'INNER JOIN', 'ctd_id = ct_tag_id' ]
+ ]
+ ) );
+ }
+
public function testDeleteWithoutTagPermission() {
$this->setExpectedException( ApiUsageException::class,
'You do not have permission to apply change tags along with your changes.' );
'testing-nontext' => 'DummyNonTextContentHandler',
'testing-serialize-error' => 'DummySerializeErrorContentHandler',
] );
+ $this->tablesUsed = array_merge(
+ $this->tablesUsed,
+ [ 'change_tag', 'change_tag_def', 'logging' ]
+ );
}
public function testEdit() {
}
public function testEditWithTag() {
+ $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
$name = 'Help:' . ucfirst( __FUNCTION__ );
ChangeTags::defineTag( 'custom tag' );
'change_tag', 'ct_tag', [ 'ct_rev_id' => $revId ], __METHOD__ ) );
}
+ public function testEditWithTagNewBackend() {
+ $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
+ $name = 'Help:' . ucfirst( __FUNCTION__ );
+
+ ChangeTags::defineTag( 'custom tag' );
+
+ $revId = $this->doApiRequestWithToken( [
+ 'action' => 'edit',
+ 'title' => $name,
+ 'text' => 'Some text',
+ 'tags' => 'custom tag',
+ ] )[0]['edit']['newrevid'];
+
+ $dbw = wfGetDB( DB_MASTER );
+ $this->assertSame( 'custom tag', $dbw->selectField(
+ [ 'change_tag', 'change_tag_def' ],
+ 'ctd_name',
+ [ 'ct_rev_id' => $revId ],
+ __METHOD__,
+ [ 'change_tag_def' => [ 'INNER JOIN', 'ctd_id = ct_tag_id' ] ]
+ )
+ );
+ }
+
public function testEditWithoutTagPermission() {
$name = 'Help:' . ucfirst( __FUNCTION__ );
* @covers ApiUserrights
*/
class ApiUserrightsTest extends ApiTestCase {
+
+ protected function setUp() {
+ parent::setUp();
+ $this->tablesUsed = array_merge(
+ $this->tablesUsed,
+ [ 'change_tag', 'change_tag_def', 'logging' ]
+ );
+ }
+
/**
* Unsets $wgGroupPermissions['bureaucrat']['userrights'], and sets
* $wgAddGroups['bureaucrat'] and $wgRemoveGroups['bureaucrat'] to the
}
public function testWithTag() {
+ $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
ChangeTags::defineTag( 'custom tag' );
$user = $this->getMutableTestUser()->getUser();
);
}
+ public function testWithTagNewBackend() {
+ $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
+ ChangeTags::defineTag( 'custom tag' );
+
+ $user = $this->getMutableTestUser()->getUser();
+
+ $this->doSuccessfulRightsChange( 'sysop', [ 'tags' => 'custom tag' ], $user );
+
+ $dbr = wfGetDB( DB_REPLICA );
+ $this->assertSame(
+ 'custom tag',
+ $dbr->selectField(
+ [ 'change_tag', 'logging', 'change_tag_def' ],
+ 'ctd_name',
+ [
+ 'ct_log_id = log_id',
+ 'log_namespace' => NS_USER,
+ 'log_title' => strtr( $user->getName(), ' ', '_' )
+ ],
+ __METHOD__,
+ [ 'change_tag_def' => [ 'INNER JOIN', 'ctd_id = ct_tag_id' ] ]
+ )
+ );
+ }
+
public function testWithoutTagPermission() {
global $wgGroupPermissions;