Update API tests to comply with the new backend for change tags
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiEditPageTest.php
index 852812b..847316a 100644 (file)
@@ -33,6 +33,10 @@ class ApiEditPageTest extends ApiTestCase {
                        'testing-nontext' => 'DummyNonTextContentHandler',
                        'testing-serialize-error' => 'DummySerializeErrorContentHandler',
                ] );
+               $this->tablesUsed = array_merge(
+                       $this->tablesUsed,
+                       [ 'change_tag', 'change_tag_def', 'logging' ]
+               );
        }
 
        public function testEdit() {
@@ -1328,6 +1332,7 @@ class ApiEditPageTest extends ApiTestCase {
        }
 
        public function testEditWithTag() {
+               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
                $name = 'Help:' . ucfirst( __FUNCTION__ );
 
                ChangeTags::defineTag( 'custom tag' );
@@ -1344,6 +1349,30 @@ class ApiEditPageTest extends ApiTestCase {
                        '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__ );