summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/api/format
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-17 09:15:42 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-17 09:44:51 +0100
commita1789ddde42033f1b05cc4929491214ee6e79383 (patch)
tree63615735c4ddffaaabf2428946bb26f90899f7bf /tests/phpunit/includes/api/format
parent9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff)
Update to MediaWiki 1.26.0
Diffstat (limited to 'tests/phpunit/includes/api/format')
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatDumpTest.php63
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatWddxTest.php80
2 files changed, 0 insertions, 143 deletions
diff --git a/tests/phpunit/includes/api/format/ApiFormatDumpTest.php b/tests/phpunit/includes/api/format/ApiFormatDumpTest.php
deleted file mode 100644
index c0f67f8d..00000000
--- a/tests/phpunit/includes/api/format/ApiFormatDumpTest.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-/**
- * @group API
- * @covers ApiFormatDump
- */
-class ApiFormatDumpTest extends ApiFormatTestBase {
-
- protected $printerName = 'dump';
-
- public static function provideGeneralEncoding() {
- // Sigh. Docs claim it's a boolean, but can have values 0, 1, or 2.
- // Fortunately wfIniGetBool does the right thing.
- if ( wfIniGetBool( 'xdebug.overload_var_dump' ) ) {
- return array(
- array( array(), 'Cannot test ApiFormatDump when xDebug overloads var_dump', array( 'SKIP' => true ) ),
- );
- }
-
- $warning = "\n [\"warnings\"]=>\n array(1) {\n [\"dump\"]=>\n array(1) {\n [\"*\"]=>\n" .
- " string(64) \"format=dump has been deprecated. Please use format=json instead.\"\n" .
- " }\n }";
-
- return array(
- // Basic types
- array( array( null ), "array(2) {{$warning}\n [0]=>\n NULL\n}\n" ),
- array( array( true ), "array(2) {{$warning}\n [0]=>\n string(0) \"\"\n}\n" ),
- array( array( false ), "array(1) {{$warning}\n}\n" ),
- array( array( true, ApiResult::META_BC_BOOLS => array( 0 ) ),
- "array(2) {{$warning}\n [0]=>\n bool(true)\n}\n" ),
- array( array( false, ApiResult::META_BC_BOOLS => array( 0 ) ),
- "array(2) {{$warning}\n [0]=>\n bool(false)\n}\n" ),
- array( array( 42 ), "array(2) {{$warning}\n [0]=>\n int(42)\n}\n" ),
- array( array( 42.5 ), "array(2) {{$warning}\n [0]=>\n float(42.5)\n}\n" ),
- array( array( 1e42 ), "array(2) {{$warning}\n [0]=>\n float(1.0E+42)\n}\n" ),
- array( array( 'foo' ), "array(2) {{$warning}\n [0]=>\n string(3) \"foo\"\n}\n" ),
- array( array( 'fóo' ), "array(2) {{$warning}\n [0]=>\n string(4) \"fóo\"\n}\n" ),
-
- // Arrays
- array( array( array() ), "array(2) {{$warning}\n [0]=>\n array(0) {\n }\n}\n" ),
- array( array( array( 1 ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n int(1)\n }\n}\n" ),
- array( array( array( 'x' => 1 ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [\"x\"]=>\n int(1)\n }\n}\n" ),
- array( array( array( 2 => 1 ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [2]=>\n int(1)\n }\n}\n" ),
- array( array( (object)array() ), "array(2) {{$warning}\n [0]=>\n array(0) {\n }\n}\n" ),
- array( array( array( 1, ApiResult::META_TYPE => 'assoc' ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n int(1)\n }\n}\n" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'array' ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n int(1)\n }\n}\n" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'kvp' ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [\"x\"]=>\n int(1)\n }\n}\n" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'BCkvp', ApiResult::META_KVP_KEY_NAME => 'key' ) ),
- "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n array(2) {\n [\"key\"]=>\n string(1) \"x\"\n [\"*\"]=>\n int(1)\n }\n }\n}\n" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'BCarray' ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [\"x\"]=>\n int(1)\n }\n}\n" ),
- array( array( array( 'a', 'b', ApiResult::META_TYPE => 'BCassoc' ) ), "array(2) {{$warning}\n [0]=>\n array(2) {\n [0]=>\n string(1) \"a\"\n [1]=>\n string(1) \"b\"\n }\n}\n" ),
-
- // Content
- array( array( 'content' => 'foo', ApiResult::META_CONTENT => 'content' ),
- "array(2) {{$warning}\n [\"*\"]=>\n string(3) \"foo\"\n}\n" ),
-
- // BC Subelements
- array( array( 'foo' => 'foo', ApiResult::META_BC_SUBELEMENTS => array( 'foo' ) ),
- "array(2) {{$warning}\n [\"foo\"]=>\n array(1) {\n [\"*\"]=>\n string(3) \"foo\"\n }\n}\n" ),
- );
- }
-
-}
diff --git a/tests/phpunit/includes/api/format/ApiFormatWddxTest.php b/tests/phpunit/includes/api/format/ApiFormatWddxTest.php
deleted file mode 100644
index 07111300..00000000
--- a/tests/phpunit/includes/api/format/ApiFormatWddxTest.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-/**
- * @group API
- * @covers ApiFormatWddx
- */
-class ApiFormatWddxTest extends ApiFormatTestBase {
-
- protected $printerName = 'wddx';
-
- public static function provideGeneralEncoding() {
- if ( ApiFormatWddx::useSlowPrinter() ) {
- return array(
- array( array(), 'Fast Wddx printer is unavailable', array( 'SKIP' => true ) )
- );
- }
- return self::provideEncoding();
- }
-
- public static function provideEncoding() {
- $p = '<wddxPacket version=\'1.0\'><header/><data><struct><var name=\'warnings\'><struct><var name=\'wddx\'><struct><var name=\'*\'><string>format=wddx has been deprecated. Please use format=json instead.</string></var></struct></var></struct></var>';
- $s = '</struct></data></wddxPacket>';
-
- return array(
- // Basic types
- array( array( null ), "{$p}<var name='0'><null/></var>{$s}" ),
- array( array( true ), "{$p}<var name='0'><string></string></var>{$s}" ),
- array( array( false ), "{$p}{$s}" ),
- array( array( true, ApiResult::META_BC_BOOLS => array( 0 ) ),
- "{$p}<var name='0'><boolean value='true'/></var>{$s}" ),
- array( array( false, ApiResult::META_BC_BOOLS => array( 0 ) ),
- "{$p}<var name='0'><boolean value='false'/></var>{$s}" ),
- array( array( 42 ), "{$p}<var name='0'><number>42</number></var>{$s}" ),
- array( array( 42.5 ), "{$p}<var name='0'><number>42.5</number></var>{$s}" ),
- array( array( 1e42 ), "{$p}<var name='0'><number>1.0E+42</number></var>{$s}" ),
- array( array( 'foo' ), "{$p}<var name='0'><string>foo</string></var>{$s}" ),
- array( array( 'fóo' ), "{$p}<var name='0'><string>fóo</string></var>{$s}" ),
-
- // Arrays and objects
- array( array( array() ), "{$p}<var name='0'><array length='0'></array></var>{$s}" ),
- array( array( array( 1 ) ), "{$p}<var name='0'><array length='1'><number>1</number></array></var>{$s}" ),
- array( array( array( 'x' => 1 ) ), "{$p}<var name='0'><struct><var name='x'><number>1</number></var></struct></var>{$s}" ),
- array( array( array( 2 => 1 ) ), "{$p}<var name='0'><struct><var name='2'><number>1</number></var></struct></var>{$s}" ),
- array( array( (object)array() ), "{$p}<var name='0'><struct></struct></var>{$s}" ),
- array( array( array( 1, ApiResult::META_TYPE => 'assoc' ) ), "{$p}<var name='0'><struct><var name='0'><number>1</number></var></struct></var>{$s}" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'array' ) ), "{$p}<var name='0'><array length='1'><number>1</number></array></var>{$s}" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'kvp' ) ), "{$p}<var name='0'><struct><var name='x'><number>1</number></var></struct></var>{$s}" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'BCkvp', ApiResult::META_KVP_KEY_NAME => 'key' ) ),
- "{$p}<var name='0'><array length='1'><struct><var name='key'><string>x</string></var><var name='*'><number>1</number></var></struct></array></var>{$s}" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'BCarray' ) ), "{$p}<var name='0'><struct><var name='x'><number>1</number></var></struct></var>{$s}" ),
- array( array( array( 'a', 'b', ApiResult::META_TYPE => 'BCassoc' ) ), "{$p}<var name='0'><array length='2'><string>a</string><string>b</string></array></var>{$s}" ),
-
- // Content
- array( array( 'content' => 'foo', ApiResult::META_CONTENT => 'content' ),
- "{$p}<var name='*'><string>foo</string></var>{$s}" ),
-
- // BC Subelements
- array( array( 'foo' => 'foo', ApiResult::META_BC_SUBELEMENTS => array( 'foo' ) ),
- "{$p}<var name='foo'><struct><var name='*'><string>foo</string></var></struct></var>{$s}" ),
- );
- }
-
- /**
- * @dataProvider provideEncoding
- */
- public function testSlowEncoding( array $data, $expect, array $params = array() ) {
- // Adjust expectation for differences between fast and slow printers.
- $expect = str_replace( '\'', '"', $expect );
- $expect = str_replace( '/>', ' />', $expect );
- $expect = '<?xml version="1.0"?>' . $expect;
-
- $this->assertSame( $expect, $this->encodeData( $params, $data, 'ApiFormatWddxTest_SlowWddx' ) );
- }
-}
-
-class ApiFormatWddxTest_SlowWddx extends ApiFormatWddx {
- public static function useSlowPrinter() {
- return true;
- }
-}