Merge "mediawiki.jqueryMsg.test.js: Additional test cases for external link"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / format / ApiFormatJsonTest.php
1 <?php
2
3 /**
4 * @group API
5 * @group Database
6 * @group medium
7 * @covers ApiFormatJson
8 */
9 class ApiFormatJsonTest extends ApiFormatTestBase {
10
11 public function testValidSyntax( ) {
12 $data = $this->apiRequest( 'json', array( 'action' => 'query', 'meta' => 'siteinfo' ) );
13
14 $this->assertInternalType( 'array', json_decode( $data, true ) );
15 $this->assertGreaterThan( 0, count( (array)$data ) );
16 }
17
18 public function testJsonpInjection( ) {
19 $data = $this->apiRequest( 'json', array( 'action' => 'query', 'meta' => 'siteinfo', 'callback' => 'myCallback' ) );
20 $this->assertEquals( '/**/myCallback(', substr( $data, 0, 15 ) );
21 }
22 }