Completed
Push — master ( 8796f9...232efd )
by
unknown
02:43
created

MsgpackSerializerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 26
loc 26
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace
4
{
5
    if (!function_exists('msgpack_pack')) {
6
        function msgpack_pack($value)
7
        {
8
            return 'bar';
9
        }
10
    }
11
}
12
13
namespace tests\MediaMonks\RestApi\Serializer
14
{
15
    use MediaMonks\RestApi\Serializer\MsgpackSerializer;
16
17
    class MsgpackSerializerTest extends \PHPUnit_Framework_TestCase
18
    {
19
        public function test_formats()
20
        {
21
            $serializer = new MsgpackSerializer();
22
            $this->assertInternalType('array', $serializer->getSupportedFormats());
23
            $this->assertEquals(['msgpack'], $serializer->getSupportedFormats());
24
            $this->assertInternalType('string', $serializer->getDefaultFormat());
25
            $this->assertEquals('msgpack', $serializer->getDefaultFormat());
26
        }
27
28
        public function test_supports()
29
        {
30
            $serializer = new MsgpackSerializer();
31
            $this->assertFalse($serializer->supportsFormat('json'));
32
            $this->assertFalse($serializer->supportsFormat('xml'));
33
            $this->assertTrue($serializer->supportsFormat('msgpack'));
34
        }
35
36
        public function test_serialize()
37
        {
38
            $serializer = new MsgpackSerializer();
39
            $output = $serializer->serialize('foo', 'msgpack');
40
            $this->assertEquals('bar', $output);
41
        }
42
    }
43
}