summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/api/format/ApiFormatJsonTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/api/format/ApiFormatJsonTest.php')
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatJsonTest.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/phpunit/includes/api/format/ApiFormatJsonTest.php b/tests/phpunit/includes/api/format/ApiFormatJsonTest.php
new file mode 100644
index 00000000..fc1f9021
--- /dev/null
+++ b/tests/phpunit/includes/api/format/ApiFormatJsonTest.php
@@ -0,0 +1,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 ) );
+ }
+}