Passed
Push — master ( 892005...6afd92 )
by Alexander
07:55
created

SerializerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 38
rs 10
wmc 2
1
<?php
2
3
namespace Yiisoft\Serializer\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use Yiisoft\Serializer\SerializerInterface;
7
8
abstract class SerializerTest extends TestCase
9
{
10
    /**
11
     * @dataProvider serializeProvider
12
     * @param $value
13
     * @param $expected
14
     */
15
    public function testSerialize($value, $expected): void
16
    {
17
        $serialized = $this->getSerializer()->serialize($value);
18
        $this->assertIsString($serialized);
19
        $this->assertEquals($expected, $serialized);
20
    }
21
22
    /**
23
     * @dataProvider unserializeProvider
24
     * @param $expected
25
     * @param $value
26
     */
27
    public function testUnserialize($expected, $value): void
28
    {
29
        $this->assertEquals($expected, $this->getSerializer()->unserialize($value));
30
    }
31
32
    /**
33
     * @return SerializerInterface
34
     */
35
    abstract public function getSerializer(): SerializerInterface;
36
37
    /**
38
     * @return array
39
     */
40
    abstract public function serializeProvider(): array;
41
42
    /**
43
     * @return array
44
     */
45
    abstract public function unserializeProvider(): array;
46
}
47