Completed
Push — master ( 298f36...c6c82d )
by Mihail
06:19 queued 10s
created

MsgpackSerializerTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
c 1
b 0
f 1
dl 0
loc 33
rs 10
wmc 5
1
<?php
2
3
namespace Koded\Stdlib\Serializer;
4
5
use Koded\Stdlib\Interfaces\Serializer;
6
use PHPUnit\Framework\TestCase;
7
8
class MsgpackSerializerTest extends TestCase
9
{
10
11
    /** @var MsgpackSerializer */
12
    private $SUT;
13
14
    private $original;
15
    private $msg;
16
17
    public function test_serialize()
18
    {
19
        $this->assertEquals(\msgpack_pack($this->original), $this->SUT->serialize($this->original));
20
    }
21
22
    public function test_unserialize()
23
    {
24
        $this->assertEquals($this->original, $this->SUT->unserialize($this->msg));
25
    }
26
27
    public function testName()
28
    {
29
        $this->assertSame(Serializer::MSGPACK, $this->SUT->type());
30
    }
31
32
    protected function setUp(): void
33
    {
34
        if (false === extension_loaded('msgpack')) {
35
            $this->markTestSkipped('msgpack extension is not loaded');
36
        }
37
38
        $this->SUT = new MsgpackSerializer;
39
        $this->original = require __DIR__ . '/../fixtures/config-test.php';
40
        $this->msg = \msgpack_pack($this->original);
41
    }
42
}
43