--- /dev/null
+<?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 ) );
+ }
+}
* @group API
* @group Database
* @group medium
+ * @covers ApiFormatPhp
*/
class ApiFormatPhpTest extends ApiFormatTestBase {
- public function testValidPhpSyntax() {
-
+ public function testValidyntax( ) {
$data = $this->apiRequest( 'php', array( 'action' => 'query', 'meta' => 'siteinfo' ) );
$this->assertInternalType( 'array', unserialize( $data ) );
<?php
abstract class ApiFormatTestBase extends ApiTestCase {
+
+ /**
+ * @param string $format
+ * @param array $params
+ * @param $data
+ *
+ * @return string
+ */
protected function apiRequest( $format, $params, $data = null ) {
$data = parent::doApiRequest( $params, $data, true );
+ /** @var ApiMain $module */
$module = $data[3];
$printer = $module->createPrinterByName( $format );
return $out;
}
+
}
--- /dev/null
+<?php
+
+/**
+ * @group API
+ * @group Database
+ * @group medium
+ * @covers ApiFormatWddx
+ */
+class ApiFormatWddxTest extends ApiFormatTestBase {
+
+ public function testValidSyntax( ) {
+ $data = $this->apiRequest( 'wddx', array( 'action' => 'query', 'meta' => 'siteinfo' ) );
+
+ $this->assertInternalType( 'array', wddx_deserialize( $data ) );
+ $this->assertGreaterThan( 0, count( (array)$data ) );
+ }
+}