Merge "Optionally collect context in TestLogger"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiParseTest.php
1 <?php
2
3 /**
4 * @group API
5 * @group Database
6 * @group medium
7 *
8 * @covers ApiParse
9 */
10 class ApiParseTest extends ApiTestCase {
11
12 protected function setUp() {
13 parent::setUp();
14 $this->doLogin();
15 }
16
17 public function testParseNonexistentPage() {
18 $somePage = mt_rand();
19
20 try {
21 $this->doApiRequest( [
22 'action' => 'parse',
23 'page' => $somePage ] );
24
25 $this->fail( "API did not return an error when parsing a nonexistent page" );
26 } catch ( ApiUsageException $ex ) {
27 $this->assertTrue( ApiTestCase::apiExceptionHasCode( $ex, 'missingtitle' ),
28 "Parse request for nonexistent page must give 'missingtitle' error: "
29 . var_export( self::getErrorFormatter()->arrayFromStatus( $ex->getStatusValue() ), true )
30 );
31 }
32 }
33 }