Merge "Add PHPUnit test to ApiQueryDisabled"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 12 Aug 2018 22:50:15 +0000 (22:50 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 12 Aug 2018 22:50:15 +0000 (22:50 +0000)
tests/phpunit/includes/api/ApiQueryDisabledTest.php [new file with mode: 0644]

diff --git a/tests/phpunit/includes/api/ApiQueryDisabledTest.php b/tests/phpunit/includes/api/ApiQueryDisabledTest.php
new file mode 100644 (file)
index 0000000..52f1fdf
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * @group API
+ * @group medium
+ *
+ * @covers ApiQueryDisabled
+ */
+class ApiQueryDisabledTest extends ApiTestCase {
+       public function testDisabled() {
+               $this->mergeMwGlobalArrayValue( 'wgAPIPropModules',
+                       [ 'categories' => 'ApiQueryDisabled' ] );
+
+               $data = $this->doApiRequest( [
+                       'action' => 'query',
+                       'prop' => 'categories',
+               ] );
+
+               $this->assertArrayHasKey( 'warnings', $data[0] );
+               $this->assertArrayHasKey( 'categories', $data[0]['warnings'] );
+               $this->assertArrayHasKey( 'warnings', $data[0]['warnings']['categories'] );
+
+               $this->assertEquals( 'The "categories" module has been disabled.',
+                       $data[0]['warnings']['categories']['warnings'] );
+       }
+}