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

JsonSerializerFunctionsTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 4
1
<?php
2
3
namespace Koded\Stdlib;
4
5
use Koded\Stdlib\Serializer\JsonSerializerTest;
6
use PHPUnit\Framework\TestCase;
7
8
class JsonSerializerFunctionsTest extends TestCase
9
{
10
11
    /** @dataProvider data */
12
    public function test_serialize_to_json($data)
13
    {
14
        $this->assertEquals(JsonSerializerTest::SERIALIZED_JSON, json_encode($data));
15
    }
16
17
    public function test_unserialize_json()
18
    {
19
        $this->assertEquals(
20
            json_decode(JsonSerializerTest::SERIALIZED_JSON, false),
21
            json_unserialize(JsonSerializerTest::SERIALIZED_JSON)
22
        );
23
    }
24
25
    public function test_unserialize_error()
26
    {
27
        $this->assertSame('', json_unserialize(''), 'Returns empty string on JSON decoding fails');
28
    }
29
30
    public function data()
31
    {
32
        return [
33
            [
34
                require __DIR__ . '/fixtures/config-test.php'
35
            ]
36
        ];
37
    }
38
}
39