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

SerializerTest::testSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
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