summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/api/format/ApiFormatJsonTest.php
blob: fc1f90217aac759a8e5b7e1de6aedc4c84e3a280 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

/**
 * @group API
 * @group Database
 * @group medium
 * @covers ApiFormatJson
 */
class ApiFormatJsonTest extends ApiFormatTestBase {

	public function testValidSyntax( ) {
		$data = $this->apiRequest( 'json', array( 'action' => 'query', 'meta' => 'siteinfo' ) );

		$this->assertInternalType( 'array', json_decode( $data, true ) );
		$this->assertGreaterThan( 0, count( (array)$data ) );
	}

	public function testJsonpInjection( ) {
		$data = $this->apiRequest( 'json', array( 'action' => 'query', 'meta' => 'siteinfo', 'callback' => 'myCallback' ) );
		$this->assertEquals( '/**/myCallback(', substr( $data, 0, 15 ) );
	}
}