[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace dokuwiki\test\Remote\OpenApiDoc; 4 5 use dokuwiki\Remote\OpenApiDoc\Type; 6 7 class TypeTest extends \DokuWikiTest 8 { 9 10 public function provideBaseTypes() 11 { 12 return [ 13 // [hint, jsonrpc, xmlrpc, context] 14 ['string', 'string', 'string'], 15 ['string', 'string', 'string', self::class], 16 ['int', 'int', 'int'], 17 ['int', 'int', 'int', self::class], 18 ['file', 'string', 'file'], 19 ['file', 'string', 'file', self::class], 20 ['date', 'int', 'date'], 21 ['date', 'int', 'date', self::class], 22 ['boolean', 'bool', 'bool'], 23 ['boolean', 'bool', 'bool', self::class], 24 ['false', 'bool', 'bool'], 25 ['false', 'bool', 'bool', self::class], 26 ['true', 'bool', 'bool'], 27 ['true', 'bool', 'bool', self::class], 28 ['integer', 'int', 'int'], 29 ['integer', 'int', 'int', self::class], 30 ['array', 'array', 'array'], 31 ['array', 'array', 'array', self::class], 32 ['array[]', 'array', 'array'], 33 ['array[]', 'array', 'array', self::class], 34 ['foo', 'foo', 'object'], 35 ['foo', 'foo', 'object', self::class], 36 ['foo[]', 'array', 'array'], 37 ['foo[]', 'array', 'array', self::class], 38 ['Foo', 'Foo', 'object'], 39 ['Foo', 'dokuwiki\\test\\Remote\\OpenApiDoc\\Foo', 'object', self::class], 40 ['\\Foo', 'Foo', 'object'], 41 ['\\Foo', 'Foo', 'object', self::class], 42 ]; 43 } 44 45 /** 46 * @dataProvider provideBaseTypes 47 * @param $typehint 48 * @param $expectedJSONRPCType 49 * @param $expectedXMLRPCType 50 * @param $context 51 * @return void 52 */ 53 public function testJSONBaseTypes($typehint, $expectedJSONRPCType, $expectedXMLRPCType, $context = '') 54 { 55 $type = new Type($typehint, $context); 56 $this->assertEquals($expectedJSONRPCType, $type->getJSONRPCType()); 57 } 58 59 /** 60 * @dataProvider provideBaseTypes 61 * @param $typehint 62 * @param $expectedJSONRPCType 63 * @param $expectedXMLRPCType 64 * @param $context 65 * @return void 66 */ 67 public function testXMLBaseTypes($typehint, $expectedJSONRPCType, $expectedXMLRPCType, $context = '') 68 { 69 $type = new Type($typehint, $context); 70 $this->assertEquals($expectedXMLRPCType, $type->getXMLRPCType()); 71 } 72 73 public function provideSubTypes() 74 { 75 return [ 76 ['string', ['string']], 77 ['string[]', ['array', 'string']], 78 ['string[][]', ['array', 'array', 'string']], 79 ['array[][]', ['array', 'array', 'array']], 80 ['Foo[][]', ['array', 'array', 'Foo']], 81 ['Foo[][]', ['array', 'array', 'dokuwiki\\test\\Remote\\OpenApiDoc\\Foo'], self::class], 82 ]; 83 } 84 85 /** 86 * @dataProvider provideSubTypes 87 * @param $typehint 88 * @param $expected 89 * @param $context 90 * @return void 91 */ 92 public function testSubType($typehint, $expected, $context = '') 93 { 94 $type = new Type($typehint, $context); 95 96 $result = [$type->getJSONRPCType()]; 97 while ($type = $type->getSubType()) { 98 $result[] = $type->getJSONRPCType(); 99 } 100 101 $this->assertEquals($expected, $result); 102 } 103 104 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body