Completed
Pull Request — master (#107)
by Alex
05:30
created

EntitySetAnonymousTypeTest::testSetBadEntityType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
dl 15
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\Tests\v3\edm\EntityContainer;
4
5
use AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\EntitySetAnonymousType;
6
use AlgoWeb\ODataMetadata\Tests\TestCase;
7
use Mockery as m;
8
9
class EntitySetAnonymousTypeTest extends TestCase
10
{
11 View Code Duplication
    public function testSetBadName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
    {
13
        $expected = "Name must be a valid TSimpleIdentifier";
14
        $actual = null;
15
16
        $foo = new EntitySetAnonymousType();
17
        $name = " _ ";
18
19
        try {
20
            $foo->setName($name);
21
        } catch (\InvalidArgumentException $e) {
22
            $actual = $e->getMessage();
23
        }
24
        $this->assertEquals($expected, $actual);
25
    }
26
27 View Code Duplication
    public function testSetBadEntityType()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
    {
29
        $expected = "Entity type must be a valid TQualifiedName";
30
        $actual = null;
31
32
        $foo = new EntitySetAnonymousType();
33
        $name = " _ ";
34
35
        try {
36
            $foo->setEntityType($name);
37
        } catch (\InvalidArgumentException $e) {
38
            $actual = $e->getMessage();
39
        }
40
        $this->assertEquals($expected, $actual);
41
    }
42
43 View Code Duplication
    public function testSetBadGetterAccess()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45
        $expected = "Getter access must be a valid TAccess";
46
        $actual = null;
47
48
        $foo = new EntitySetAnonymousType();
49
        $name = " _ ";
50
51
        try {
52
            $foo->setGetterAccess($name);
53
        } catch (\InvalidArgumentException $e) {
54
            $actual = $e->getMessage();
55
        }
56
        $this->assertEquals($expected, $actual);
57
    }
58
59 View Code Duplication
    public function testIsTEntitySetAttributesOKBadName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
    {
61
        $expectedStarts = "Name must be a valid TSimpleIdentifier";
62
        $expectedEnds = "AlgoWeb_ODataMetadata_MetadataV3_edm_EntityContainer_EntitySetAnonymousType";
63
        $actual = null;
64
65
        $foo = m::mock(EntitySetAnonymousType::class)->makePartial();
66
        $foo->shouldReceive('isTSimpleIdentifierValid')->andReturn(true, false)->twice();
67
        
68
        $foo->setName(" _ ");
69
        
70
        $this->assertFalse($foo->isTEntitySetAttributesOK($actual));
71
        $this->assertStringStartsWith($expectedStarts, $actual);
72
        $this->assertStringEndsWith($expectedEnds, $actual);
73
    }
74
75 View Code Duplication
    public function testIsTEntitySetAttributesOKBadEntityType()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
    {
77
        $expectedStarts = "Entity type must be a valid TQualifiedName";
78
        $expectedEnds = "AlgoWeb_ODataMetadata_MetadataV3_edm_EntityContainer_EntitySetAnonymousType";
79
        $actual = null;
80
81
        $foo = m::mock(EntitySetAnonymousType::class)->makePartial();
82
        $foo->shouldReceive('isTQualifiedNameValid')->andReturn(true, false)->twice();
83
84
        $foo->setEntityType(" _ ");
85
86
        $this->assertFalse($foo->isTEntitySetAttributesOK($actual));
87
        $this->assertStringStartsWith($expectedStarts, $actual);
88
        $this->assertStringEndsWith($expectedEnds, $actual);
89
    }
90
91 View Code Duplication
    public function testIsTEntitySetAttributesOKBadGetterAccess()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
92
    {
93
        $expectedStarts = "Getter access must be a valid TAccess";
94
        $expectedEnds = "AlgoWeb_ODataMetadata_MetadataV3_edm_EntityContainer_EntitySetAnonymousType";
95
        $actual = null;
96
97
        $foo = m::mock(EntitySetAnonymousType::class)->makePartial();
98
        $foo->shouldReceive('isTAccessOk')->andReturn(true, false)->twice();
99
100
        $foo->setGetterAccess(" _ ");
101
102
        $this->assertFalse($foo->isTEntitySetAttributesOK($actual));
103
        $this->assertStringStartsWith($expectedStarts, $actual);
104
        $this->assertStringEndsWith($expectedEnds, $actual);
105
    }
106
}
107