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

TEnumTypeMemberTypeTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 30.77 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 12
loc 39
rs 10
c 0
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\TDocumentationType;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\TEnumTypeMemberType;
7
use AlgoWeb\ODataMetadata\Tests\TestCase;
8
use Mockery as m;
9
10
class TEnumTypeMemberTypeTest extends TestCase
11
{
12
    public function testPreserveString()
13
    {
14
        $foo = new TEnumTypeMemberType();
15
        $expected = ' string ';
16
        $actual = $foo->preserveString($expected);
17
        $this->assertEquals($expected, $actual);
18
    }
19
20
    public function testSetDocumentationNotOk()
21
    {
22
        $expected = '';
23
        $actual = null;
24
        $foo = new TEnumTypeMemberType();
25
        $documentation = m::mock(TDocumentationType::class);
26
        $documentation->shouldReceive('isOK')->andReturn(false)->once();
27
28
        try {
29
            $foo->setDocumentation($documentation);
30
        } catch (\InvalidArgumentException $e) {
31
            $actual = $e->getMessage();
32
        }
33
        $this->assertEquals($expected, $actual);
34
    }
35
36
    public function testIsExtensibilityElementOKNoGoodnik()
37
    {
38
        $expected = '';
39
        $actual = null;
40
        $foo = new TEnumTypeMemberType();
41
        $documentation = m::mock(TDocumentationType::class);
42
        $documentation->shouldReceive('isOK')->andReturn(true, false)->twice();
43
44
        $foo->setDocumentation($documentation);
45
        $this->assertFalse($foo->isExtensibilityElementOK($actual));
46
        $this->assertEquals($expected, $actual);
47
    }
48
}
49