Add tests to ensure that NamespaceRestrictions are returned from Block APIs.
authorDavid Barratt <dbarratt@wikimedia.org>
Thu, 15 Nov 2018 22:32:09 +0000 (17:32 -0500)
committerDbarratt <dbarratt@wikimedia.org>
Wed, 23 Jan 2019 21:31:12 +0000 (21:31 +0000)
Bug: T204989
Change-Id: Ibe44da41e9efa6688615dc9b0712f9713d4e8158

tests/phpunit/includes/api/ApiQueryBlocksTest.php

index dc7d450..03198a8 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use MediaWiki\Block\Restriction\PageRestriction;
+use MediaWiki\Block\Restriction\NamespaceRestriction;
 
 /**
  * @group API
@@ -113,8 +114,13 @@ class ApiQueryBlocksTest extends ApiTestCase {
                ] );
                $this->db->insert( 'ipblocks_restrictions', [
                        'ir_ipb_id' => $block->getId(),
-                       'ir_type' => 2,
-                       'ir_value' => 3,
+                       'ir_type' => NamespaceRestriction::TYPE_ID,
+                       'ir_value' => NS_USER_TALK,
+               ] );
+               $this->db->insert( 'ipblocks_restrictions', [
+                       'ir_ipb_id' => $block->getId(),
+                       'ir_type' => 3,
+                       'ir_value' => 4,
                ] );
 
                // Test without requesting restrictions.
@@ -149,6 +155,9 @@ class ApiQueryBlocksTest extends ApiTestCase {
                                                'title' => $title,
                                        ],
                                ],
+                               'namespaces' => [
+                                       NS_USER_TALK,
+                               ],
                        ],
                ] );
                $this->assertArraySubset( $restrictionsSubset, $data['query']['blocks'][0] );