From 95779682802ed1bc3ae7bb289ab906c04d7b405a Mon Sep 17 00:00:00 2001 From: addshore Date: Wed, 23 Oct 2013 16:10:02 +0100 Subject: [PATCH] Add more ApiFormat format tests Adds tests for Json and wddx formats Add @covers tags Fixes some comments Fixes scope Change-Id: I5f22097ddcaeb917f856ba7aa0cb793caa17925e --- .../includes/api/format/ApiFormatJsonTest.php | 17 +++++++++++++++++ .../includes/api/format/ApiFormatPhpTest.php | 4 ++-- .../includes/api/format/ApiFormatTestBase.php | 10 ++++++++++ .../includes/api/format/ApiFormatWddxTest.php | 17 +++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/phpunit/includes/api/format/ApiFormatJsonTest.php create mode 100644 tests/phpunit/includes/api/format/ApiFormatWddxTest.php diff --git a/tests/phpunit/includes/api/format/ApiFormatJsonTest.php b/tests/phpunit/includes/api/format/ApiFormatJsonTest.php new file mode 100644 index 0000000000..c71faec8e2 --- /dev/null +++ b/tests/phpunit/includes/api/format/ApiFormatJsonTest.php @@ -0,0 +1,17 @@ +apiRequest( 'json', array( 'action' => 'query', 'meta' => 'siteinfo' ) ); + + $this->assertInternalType( 'array', json_decode( $data, true ) ); + $this->assertGreaterThan( 0, count( (array)$data ) ); + } +} diff --git a/tests/phpunit/includes/api/format/ApiFormatPhpTest.php b/tests/phpunit/includes/api/format/ApiFormatPhpTest.php index a0bbb2dc7d..759dfc71d0 100644 --- a/tests/phpunit/includes/api/format/ApiFormatPhpTest.php +++ b/tests/phpunit/includes/api/format/ApiFormatPhpTest.php @@ -4,11 +4,11 @@ * @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 ) ); diff --git a/tests/phpunit/includes/api/format/ApiFormatTestBase.php b/tests/phpunit/includes/api/format/ApiFormatTestBase.php index 153f2cf46d..24d8cb8a2b 100644 --- a/tests/phpunit/includes/api/format/ApiFormatTestBase.php +++ b/tests/phpunit/includes/api/format/ApiFormatTestBase.php @@ -1,9 +1,18 @@ createPrinterByName( $format ); @@ -19,4 +28,5 @@ abstract class ApiFormatTestBase extends ApiTestCase { return $out; } + } diff --git a/tests/phpunit/includes/api/format/ApiFormatWddxTest.php b/tests/phpunit/includes/api/format/ApiFormatWddxTest.php new file mode 100644 index 0000000000..2cf6dcafb4 --- /dev/null +++ b/tests/phpunit/includes/api/format/ApiFormatWddxTest.php @@ -0,0 +1,17 @@ +apiRequest( 'wddx', array( 'action' => 'query', 'meta' => 'siteinfo' ) ); + + $this->assertInternalType( 'array', wddx_deserialize( $data ) ); + $this->assertGreaterThan( 0, count( (array)$data ) ); + } +} -- 2.20.1