Merge "Add semantic tags to license info text"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiBaseTest.php
index 253ac95..575f0c9 100644 (file)
@@ -51,6 +51,7 @@ class ApiBaseTest extends ApiTestCase {
         * @param array $paramSettings
         * @param mixed $expected
         * @param string[] $warnings
+        * @covers ApiBase::getParameterFromSettings
         */
        public function testGetParameterFromSettings( $input, $paramSettings, $expected, $warnings ) {
                $mock = new MockApi();
@@ -126,6 +127,9 @@ class ApiBaseTest extends ApiTestCase {
                ];
        }
 
+       /**
+        * @covers ApiBase::errorArrayToStatus
+        */
        public function testErrorArrayToStatus() {
                $mock = new MockApi();
 
@@ -174,4 +178,43 @@ class ApiBaseTest extends ApiTestCase {
                ], $user ) );
        }
 
+       /**
+        * @covers ApiBase::dieStatus
+        */
+       public function testDieStatus() {
+               $mock = new MockApi();
+
+               $status = StatusValue::newGood();
+               $status->error( 'foo' );
+               $status->warning( 'bar' );
+               try {
+                       $mock->dieStatus( $status );
+                       $this->fail( 'Expected exception not thrown' );
+               } catch ( ApiUsageException $ex ) {
+                       $this->assertTrue( ApiTestCase::apiExceptionHasCode( $ex, 'foo' ), 'Exception has "foo"' );
+                       $this->assertFalse( ApiTestCase::apiExceptionHasCode( $ex, 'bar' ), 'Exception has "bar"' );
+               }
+
+               $status = StatusValue::newGood();
+               $status->warning( 'foo' );
+               $status->warning( 'bar' );
+               try {
+                       $mock->dieStatus( $status );
+                       $this->fail( 'Expected exception not thrown' );
+               } catch ( ApiUsageException $ex ) {
+                       $this->assertTrue( ApiTestCase::apiExceptionHasCode( $ex, 'foo' ), 'Exception has "foo"' );
+                       $this->assertTrue( ApiTestCase::apiExceptionHasCode( $ex, 'bar' ), 'Exception has "bar"' );
+               }
+
+               $status = StatusValue::newGood();
+               $status->setOk( false );
+               try {
+                       $mock->dieStatus( $status );
+                       $this->fail( 'Expected exception not thrown' );
+               } catch ( ApiUsageException $ex ) {
+                       $this->assertTrue( ApiTestCase::apiExceptionHasCode( $ex, 'unknownerror-nocode' ),
+                               'Exception has "unknownerror-nocode"' );
+               }
+       }
+
 }