2013-10-23 15:10:02 +00:00
|
|
|
<?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 ) );
|
|
|
|
|
}
|
2014-07-17 20:24:56 +00:00
|
|
|
|
|
|
|
|
public function testJsonpInjection( ) {
|
|
|
|
|
$data = $this->apiRequest( 'json', array( 'action' => 'query', 'meta' => 'siteinfo', 'callback' => 'myCallback' ) );
|
|
|
|
|
$this->assertEquals( '/**/myCallback(', substr( $data, 0, 15 ) );
|
|
|
|
|
}
|
2013-10-23 15:10:02 +00:00
|
|
|
}
|