1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yiisoft\Serializer\Tests; |
4
|
|
|
|
5
|
|
|
use Yiisoft\Serializer\IgbinarySerializer; |
6
|
|
|
use Yiisoft\Serializer\SerializerInterface; |
7
|
|
|
|
8
|
|
|
class IgbinarySerializerTest extends SerializerTest |
9
|
|
|
{ |
10
|
|
|
public static function setUpBeforeClass(): void |
11
|
|
|
{ |
12
|
|
|
if (!extension_loaded('igbinary')) { |
13
|
|
|
static::markTestSkipped('igbinary extension is not loaded'); |
14
|
|
|
} |
15
|
|
|
parent::setUpBeforeClass(); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function getSerializer(): SerializerInterface |
19
|
|
|
{ |
20
|
|
|
return new IgbinarySerializer(); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function serializeProvider(): array |
24
|
|
|
{ |
25
|
|
|
return $this->dataProvider(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function unserializeProvider(): array |
29
|
|
|
{ |
30
|
|
|
return $this->dataProvider(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function dataProvider(): array |
34
|
|
|
{ |
35
|
|
|
return [ |
36
|
|
|
'int' => [1, hex2bin('000000020601'),], |
37
|
|
|
'float' => [1.1, hex2bin('000000020c3ff199999999999a'),], |
38
|
|
|
'string' => ['a', hex2bin('00000002110161'),], |
39
|
|
|
'null' => [null, hex2bin('0000000200'),], |
40
|
|
|
'bool' => [true, hex2bin('0000000205'),], |
41
|
|
|
'object' => [new \stdClass(), hex2bin('000000021708737464436c6173731400'),], |
42
|
|
|
'array' => [[], hex2bin('000000021400'),], |
43
|
|
|
]; |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|