Add PHPUnit test to ApiQueryDisabled
authordcot <dacot11@yahoo.com>
Thu, 2 Aug 2018 17:21:05 +0000 (13:21 -0400)
committerdcot <dacot11@yahoo.com>
Fri, 3 Aug 2018 01:44:24 +0000 (21:44 -0400)
This change adds a PHPUnit test to ApiQueryDisabled as requested in T183885.
A PHPUnit test for ApiDisabled was already in place.

Bug: T183885
Change-Id: I7726c27a5ca74ce26f095afd13af4a71babea82e

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'] );
+       }
+}