Merge "search: Fix DYM typos in widget"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiDeleteTest.php
index 0f2bcc6..f2db1b2 100644 (file)
  * @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__ );
 
@@ -65,6 +74,7 @@ class ApiDeleteTest extends ApiTestCase {
        }
 
        public function testDeleteWithTag() {
+               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
                $name = 'Help:' . ucfirst( __FUNCTION__ );
 
                ChangeTags::defineTag( 'custom tag' );
@@ -93,6 +103,39 @@ class ApiDeleteTest extends ApiTestCase {
                ) );
        }
 
+       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.' );