1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\Tests\v3\edm\EntityContainer\AssociationSetAnonymousType; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\AssociationSetAnonymousType\EndAnonymousType; |
6
|
|
|
use AlgoWeb\ODataMetadata\Tests\TestCase; |
7
|
|
|
use Mockery as m; |
8
|
|
|
|
9
|
|
|
class EndAnonymousTypeTest extends TestCase |
10
|
|
|
{ |
11
|
|
|
public function testSetBadRole() |
12
|
|
|
{ |
13
|
|
|
$expected = "Role must be a valid TSimpleIdentifier"; |
14
|
|
|
$actual = null; |
15
|
|
|
|
16
|
|
|
$foo = new EndAnonymousType(); |
17
|
|
|
|
18
|
|
|
try { |
19
|
|
|
$foo->setRole(" _ "); |
20
|
|
|
} catch (\InvalidArgumentException $e) { |
21
|
|
|
$actual = $e->getMessage(); |
22
|
|
|
} |
23
|
|
|
$this->assertEquals($expected, $actual); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testSetBadEntitySet() |
27
|
|
|
{ |
28
|
|
|
$expected = "Entity set must be a valid TSimpleIdentifier"; |
29
|
|
|
$actual = null; |
30
|
|
|
|
31
|
|
|
$foo = new EndAnonymousType(); |
32
|
|
|
|
33
|
|
|
try { |
34
|
|
|
$foo->setEntitySet(" _ "); |
35
|
|
|
} catch (\InvalidArgumentException $e) { |
36
|
|
|
$actual = $e->getMessage(); |
37
|
|
|
} |
38
|
|
|
$this->assertEquals($expected, $actual); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testNewCreationIsNotOK() |
42
|
|
|
{ |
43
|
|
|
$expected = "Entity set must be a valid TSimpleIdentifier"; |
44
|
|
|
$actual = null; |
45
|
|
|
|
46
|
|
|
$foo = new EndAnonymousType(); |
47
|
|
|
$this->assertFalse($foo->isOK($actual)); |
48
|
|
|
$this->assertEquals($expected, $actual); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testIsOkWithBadRole() |
52
|
|
|
{ |
53
|
|
|
$expected = "Role must be a valid TSimpleIdentifier"; |
54
|
|
|
$actual = null; |
55
|
|
|
|
56
|
|
|
$foo = m::mock(EndAnonymousType::class)->makePartial(); |
57
|
|
|
$foo->shouldReceive('isTSimpleIdentifierValid')->andReturn(true, true, true, false)->times(4); |
58
|
|
|
$foo->setEntitySet("UnitPrice"); |
59
|
|
|
$foo->setRole(" _ "); |
60
|
|
|
$this->assertFalse($foo->isOK($actual)); |
61
|
|
|
$this->assertEquals($expected, $actual); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|