|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\Tests\v3\edm; |
|
4
|
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionType; |
|
6
|
|
|
use AlgoWeb\ODataMetadata\Tests\TestCase; |
|
7
|
|
|
use Mockery as m; |
|
8
|
|
|
|
|
9
|
|
|
class TFunctionTypeTest extends TestCase |
|
10
|
|
|
{ |
|
11
|
|
|
public function testIsSridFacetValidNonNegativeInteger() |
|
12
|
|
|
{ |
|
13
|
|
|
$foo = m::mock(TFunctionType::class)->makePartial(); |
|
14
|
|
|
$foo->shouldReceive('isTVariableValid')->andReturn(false)->once(); |
|
15
|
|
|
$this->assertTrue($foo->isTSridFacetValid('6')); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function testIsSridFacetValidNegativeInteger() |
|
19
|
|
|
{ |
|
20
|
|
|
$expected = 'Input must be non-negative integer'; |
|
21
|
|
|
$actual = null; |
|
22
|
|
|
|
|
23
|
|
|
$foo = m::mock(TFunctionType::class)->makePartial(); |
|
24
|
|
|
$foo->shouldReceive('isTVariableValid')->andReturn(false)->once(); |
|
25
|
|
|
|
|
26
|
|
|
try { |
|
27
|
|
|
$foo->isTSridFacetValid('-6'); |
|
28
|
|
|
} catch (\InvalidArgumentException $e) { |
|
29
|
|
|
$actual = $e->getMessage(); |
|
30
|
|
|
} |
|
31
|
|
|
$this->assertEquals($expected, $actual); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testIsSridFacetValidNonNegativeFloat() |
|
35
|
|
|
{ |
|
36
|
|
|
$expected = 'Input must be integer'; |
|
37
|
|
|
$actual = null; |
|
38
|
|
|
|
|
39
|
|
|
$foo = m::mock(TFunctionType::class)->makePartial(); |
|
40
|
|
|
$foo->shouldReceive('isTVariableValid')->andReturn(false)->once(); |
|
41
|
|
|
try { |
|
42
|
|
|
$foo->isTSridFacetValid('6.5'); |
|
43
|
|
|
} catch (\InvalidArgumentException $e) { |
|
44
|
|
|
$actual = $e->getMessage(); |
|
45
|
|
|
} |
|
46
|
|
|
$this->assertEquals($expected, $actual); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function testIsSridFacetValidNegativeFloat() |
|
50
|
|
|
{ |
|
51
|
|
|
$expected = 'Input must be integer'; |
|
52
|
|
|
$actual = null; |
|
53
|
|
|
|
|
54
|
|
|
$foo = m::mock(TFunctionType::class)->makePartial(); |
|
55
|
|
|
$foo->shouldReceive('isTVariableValid')->andReturn(false)->once(); |
|
56
|
|
|
|
|
57
|
|
|
try { |
|
58
|
|
|
$foo->isTSridFacetValid('-6.5'); |
|
59
|
|
|
} catch (\InvalidArgumentException $e) { |
|
60
|
|
|
$actual = $e->getMessage(); |
|
61
|
|
|
} |
|
62
|
|
|
$this->assertEquals($expected, $actual); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function testIsSridFacetValidNonString() |
|
66
|
|
|
{ |
|
67
|
|
|
$expected = 'Input must be a string'; |
|
68
|
|
|
$actual = null; |
|
69
|
|
|
|
|
70
|
|
|
$foo = m::mock(TFunctionType::class)->makePartial(); |
|
71
|
|
|
$foo->shouldReceive('isTVariableValid')->andReturn(false)->once(); |
|
72
|
|
|
|
|
73
|
|
|
try { |
|
74
|
|
|
$foo->isTSridFacetValid(new \DateTime()); |
|
75
|
|
|
} catch (\InvalidArgumentException $e) { |
|
76
|
|
|
$actual = $e->getMessage(); |
|
77
|
|
|
} |
|
78
|
|
|
$this->assertEquals($expected, $actual); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function testPreserveStringNotAString() |
|
82
|
|
|
{ |
|
83
|
|
|
$expected = 'Input must be a string'; |
|
84
|
|
|
$actual = null; |
|
85
|
|
|
|
|
86
|
|
|
$foo = m::mock(TFunctionType::class)->makePartial(); |
|
87
|
|
|
$foo->shouldReceive('isTVariableValid')->andReturn(false)->once(); |
|
88
|
|
|
|
|
89
|
|
|
try { |
|
90
|
|
|
$foo->preserveString(new \DateTime()); |
|
91
|
|
|
} catch (\InvalidArgumentException $e) { |
|
92
|
|
|
$actual = $e->getMessage(); |
|
93
|
|
|
} |
|
94
|
|
|
$this->assertEquals($expected, $actual); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function testReplaceStringNotAString() |
|
98
|
|
|
{ |
|
99
|
|
|
$expected = 'Input must be a string'; |
|
100
|
|
|
$actual = null; |
|
101
|
|
|
|
|
102
|
|
|
$foo = m::mock(TFunctionType::class)->makePartial(); |
|
103
|
|
|
$foo->shouldReceive('isTVariableValid')->andReturn(false)->once(); |
|
104
|
|
|
|
|
105
|
|
|
try { |
|
106
|
|
|
$foo->replaceString(new \DateTime()); |
|
107
|
|
|
} catch (\InvalidArgumentException $e) { |
|
108
|
|
|
$actual = $e->getMessage(); |
|
109
|
|
|
} |
|
110
|
|
|
$this->assertEquals($expected, $actual); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|