Remove hard deprecation of PasswordPolicyChecks::checkPopularPasswordBlacklist
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiQueryBlocksTest.php
index dc7d450..e281679 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 
+use MediaWiki\Block\DatabaseBlock;
 use MediaWiki\Block\Restriction\PageRestriction;
+use MediaWiki\Block\Restriction\NamespaceRestriction;
 
 /**
  * @group API
@@ -28,7 +30,7 @@ class ApiQueryBlocksTest extends ApiTestCase {
                $badActor = $this->getTestUser()->getUser();
                $sysop = $this->getTestSysop()->getUser();
 
-               $block = new Block( [
+               $block = new DatabaseBlock( [
                        'address' => $badActor->getName(),
                        'user' => $badActor->getId(),
                        'by' => $sysop->getId(),
@@ -56,7 +58,7 @@ class ApiQueryBlocksTest extends ApiTestCase {
                $badActor = $this->getTestUser()->getUser();
                $sysop = $this->getTestSysop()->getUser();
 
-               $block = new Block( [
+               $block = new DatabaseBlock( [
                        'address' => $badActor->getName(),
                        'user' => $badActor->getId(),
                        'by' => $sysop->getId(),
@@ -86,7 +88,7 @@ class ApiQueryBlocksTest extends ApiTestCase {
                $badActor = $this->getTestUser()->getUser();
                $sysop = $this->getTestSysop()->getUser();
 
-               $block = new Block( [
+               $block = new DatabaseBlock( [
                        'address' => $badActor->getName(),
                        'user' => $badActor->getId(),
                        'by' => $sysop->getId(),
@@ -111,10 +113,21 @@ class ApiQueryBlocksTest extends ApiTestCase {
                        'ir_type' => PageRestriction::TYPE_ID,
                        'ir_value' => $pageId,
                ] );
+               // Page that has been deleted.
                $this->db->insert( 'ipblocks_restrictions', [
                        'ir_ipb_id' => $block->getId(),
-                       'ir_type' => 2,
-                       'ir_value' => 3,
+                       'ir_type' => PageRestriction::TYPE_ID,
+                       'ir_value' => 999999,
+               ] );
+               $this->db->insert( 'ipblocks_restrictions', [
+                       'ir_ipb_id' => $block->getId(),
+                       '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 +162,9 @@ class ApiQueryBlocksTest extends ApiTestCase {
                                                'title' => $title,
                                        ],
                                ],
+                               'namespaces' => [
+                                       NS_USER_TALK,
+                               ],
                        ],
                ] );
                $this->assertArraySubset( $restrictionsSubset, $data['query']['blocks'][0] );