Normalize use of "INNER JOIN" to "JOIN" in database queries
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiBlockTest.php
index 9898e53..01455ed 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+use MediaWiki\Block\Restriction\PageRestriction;
+use MediaWiki\Block\Restriction\NamespaceRestriction;
+
 /**
  * @group API
  * @group Database
@@ -128,8 +131,8 @@ class ApiBlockTest extends ApiTestCase {
                        __METHOD__,
                        [],
                        [
-                               'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ],
-                               'change_tag_def' => [ 'INNER JOIN', 'ctd_id = ct_tag_id' ],
+                               'change_tag' => [ 'JOIN', 'ct_log_id = log_id' ],
+                               'change_tag_def' => [ 'JOIN', 'ctd_id = ct_tag_id' ],
                        ]
                ) );
        }
@@ -215,6 +218,19 @@ class ApiBlockTest extends ApiTestCase {
                $this->doBlock( [ 'expiry' => '' ] );
        }
 
+       public function testBlockWithoutRestrictions() {
+               $this->setMwGlobals( [
+                       'wgEnablePartialBlocks' => true,
+               ] );
+
+               $this->doBlock();
+
+               $block = Block::newFromTarget( $this->mUser->getName() );
+
+               $this->assertTrue( $block->isSitewide() );
+               $this->assertCount( 0, $block->getRestrictions() );
+       }
+
        public function testBlockWithRestrictions() {
                $this->setMwGlobals( [
                        'wgEnablePartialBlocks' => true,
@@ -222,17 +238,22 @@ class ApiBlockTest extends ApiTestCase {
 
                $title = 'Foo';
                $page = $this->getExistingTestPage( $title );
+               $namespace = NS_TALK;
 
                $this->doBlock( [
                        'partial' => true,
                        'pagerestrictions' => $title,
+                       'namespacerestrictions' => $namespace,
                ] );
 
                $block = Block::newFromTarget( $this->mUser->getName() );
 
                $this->assertFalse( $block->isSitewide() );
-               $this->assertCount( 1, $block->getRestrictions() );
+               $this->assertCount( 2, $block->getRestrictions() );
+               $this->assertInstanceOf( PageRestriction::class, $block->getRestrictions()[0] );
                $this->assertEquals( $title, $block->getRestrictions()[0]->getTitle()->getText() );
+               $this->assertInstanceOf( NamespaceRestriction::class, $block->getRestrictions()[1] );
+               $this->assertEquals( $namespace, $block->getRestrictions()[1]->getValue() );
        }
 
        /**
@@ -274,9 +295,10 @@ class ApiBlockTest extends ApiTestCase {
 
        /**
         * @expectedException ApiUsageException
-        * @expectedExceptionMessage "pagerestrictions" may not be over 10 (set to 11) for bots or sysops.
+        * @expectedExceptionMessage Too many values supplied for parameter "pagerestrictions". The
+        * limit is 10.
         */
-       public function testBlockingToManyRestrictions() {
+       public function testBlockingToManyPageRestrictions() {
                $this->setMwGlobals( [
                        'wgEnablePartialBlocks' => true,
                ] );