Passed
Push — master ( 59e1a5...f37dc8 )
by Christopher
05:53
created

TEntityPropertyTypeTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 65
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
lcom 1
cbo 2
dl 65
loc 65
rs 10
c 1
b 0
f 0

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 AlgoWeb\ODataMetadata\Tests\v3\edm;
4
5
use AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityPropertyType;
6
use AlgoWeb\ODataMetadata\Tests\TestCase;
7
use Mockery as m;
8
9
class TEntityPropertyTypeTest extends TestCase
10
{
11
    public function testSetNullDefaultValue()
12
    {
13
        $foo = new TEntityPropertyType();
14
        $foo->setDefaultValue(null);
15
        $this->assertEquals(null, $foo->getDefaultValue());
16
    }
17
18
    public function testSetStringDefaultValue()
19
    {
20
        $foo = new TEntityPropertyType();
21
        $foo->setDefaultValue('abc');
22
        $this->assertEquals('abc', $foo->getDefaultValue());
23
    }
24
25
    public function testSetNumericDefaultValue()
26
    {
27
        $foo = new TEntityPropertyType();
28
        $foo->setDefaultValue(1234);
29
        $this->assertEquals('1234', $foo->getDefaultValue());
30
    }
31
32
    public function testSetObjectDefaultValue()
33
    {
34
        $expected = 'Default value must be resolvable to a string';
35
        $actual = null;
36
37
        $foo = new TEntityPropertyType();
38
        try {
39
            $foo->setDefaultValue(new \DateTime());
40
        } catch (\InvalidArgumentException $e) {
41
            $actual = $e->getMessage();
42
        }
43
        $this->assertEquals($expected, $actual);
44
    }
45
46
    public function testSetEmptyArrayDefaultValue()
47
    {
48
        $expected = 'Default value must be resolvable to a string';
49
        $actual = null;
50
51
        $foo = new TEntityPropertyType();
52
        try {
53
            $foo->setDefaultValue([]);
54
        } catch (\InvalidArgumentException $e) {
55
            $actual = $e->getMessage();
56
        }
57
        $this->assertEquals($expected, $actual);
58
    }
59
60
    public function testSetNonEmptyArrayDefaultValue()
61
    {
62
        $expected = 'Default value must be resolvable to a string';
63
        $actual = null;
64
65
        $foo = new TEntityPropertyType();
66
        try {
67
            $foo->setDefaultValue(['a']);
68
        } catch (\InvalidArgumentException $e) {
69
            $actual = $e->getMessage();
70
        }
71
        $this->assertEquals($expected, $actual);
72
    }
73
}
74