blob: 2b7d6072d0e0bc2b752b31af8a12de20b92be671 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<?php
namespace Mediawiki\Api\Test\Unit;
use Mediawiki\Api\UsageException;
use PHPUnit_Framework_TestCase;
/**
* @author Addshore
*
* @covers Mediawiki\Api\UsageException
*/
class UsageExceptionTest extends PHPUnit_Framework_TestCase {
public function testUsageExceptionWithNoParams() {
$e = new UsageException();
$this->assertSame(
'Code: ' . PHP_EOL .
'Message: ' . PHP_EOL .
'Result: []',
$e->getMessage()
);
$this->assertSame( '', $e->getApiCode() );
$this->assertEquals( [], $e->getApiResult() );
}
public function testUsageExceptionWithParams() {
$e = new UsageException( 'imacode', 'imamsg', [ 'foo' => 'bar' ] );
$this->assertSame( 'imacode', $e->getApiCode() );
$this->assertSame(
'Code: imacode' . PHP_EOL .
'Message: imamsg' . PHP_EOL .
'Result: {"foo":"bar"}',
$e->getMessage()
);
$this->assertEquals( [ 'foo' => 'bar' ], $e->getApiResult() );
}
}
|