10
10
namespace WikibaseSolutions \CypherDSL \Tests \Unit \Expressions \Procedures ;
11
11
12
12
use PHPUnit \Framework \TestCase ;
13
+ use WikibaseSolutions \CypherDSL \Expressions \Literals \Boolean ;
13
14
use WikibaseSolutions \CypherDSL \Expressions \Literals \List_ ;
14
15
use WikibaseSolutions \CypherDSL \Expressions \Literals \Literal ;
15
16
use WikibaseSolutions \CypherDSL \Expressions \Literals \Map ;
28
29
use WikibaseSolutions \CypherDSL \Expressions \Procedures \Single ;
29
30
use WikibaseSolutions \CypherDSL \Expressions \Procedures \Time ;
30
31
use WikibaseSolutions \CypherDSL \Expressions \Variable ;
32
+ use WikibaseSolutions \CypherDSL \Query ;
31
33
use WikibaseSolutions \CypherDSL \Types \AnyType ;
32
34
33
35
/**
34
36
* @covers \WikibaseSolutions\CypherDSL\Expressions\Procedures\Procedure
35
37
*/
36
- class ProcedureTest extends TestCase
38
+ final class ProcedureTest extends TestCase
37
39
{
38
40
public function testRaw (): void
39
41
{
@@ -44,9 +46,9 @@ public function testRaw(): void
44
46
45
47
public function testAll (): void
46
48
{
47
- $ variable = new Variable ( " a " );
48
- $ list = new List_ ;
49
- $ predicate = $ this -> createMock (AnyType::class );
49
+ $ variable = Query:: variable ( ' a ' );
50
+ $ list = Query:: list ([]) ;
51
+ $ predicate = Query:: boolean ( true );
50
52
51
53
$ all = Procedure::all ($ variable , $ list , $ predicate );
52
54
@@ -55,9 +57,9 @@ public function testAll(): void
55
57
56
58
public function testAny (): void
57
59
{
58
- $ variable = new Variable ( " a " );
59
- $ list = new List_ ;
60
- $ predicate = $ this -> createMock (AnyType::class );
60
+ $ variable = Query:: variable ( ' a ' );
61
+ $ list = Query:: list ([]) ;
62
+ $ predicate = Query:: boolean ( true );
61
63
62
64
$ any = Procedure::any ($ variable , $ list , $ predicate );
63
65
@@ -66,7 +68,7 @@ public function testAny(): void
66
68
67
69
public function testExists (): void
68
70
{
69
- $ expression = $ this -> createMock (AnyType::class );
71
+ $ expression = Query:: string ( " Hello World " );
70
72
71
73
$ exists = Procedure::exists ($ expression );
72
74
@@ -75,7 +77,7 @@ public function testExists(): void
75
77
76
78
public function testIsEmpty (): void
77
79
{
78
- $ list = new List_ ;
80
+ $ list = Query:: list ([]) ;
79
81
80
82
$ isEmpty = Procedure::isEmpty ($ list );
81
83
@@ -84,9 +86,9 @@ public function testIsEmpty(): void
84
86
85
87
public function testNone (): void
86
88
{
87
- $ variable = new Variable ( " a " );
88
- $ list = new List_ ;
89
- $ predicate = $ this -> createMock (AnyType::class );
89
+ $ variable = Query:: variable ( ' a ' );
90
+ $ list = Query:: list ([]) ;
91
+ $ predicate = Query:: boolean ( true );
90
92
91
93
$ none = Procedure::none ($ variable , $ list , $ predicate );
92
94
@@ -95,9 +97,9 @@ public function testNone(): void
95
97
96
98
public function testSingle (): void
97
99
{
98
- $ variable = new Variable ( " a " );
99
- $ list = new List_ ;
100
- $ predicate = $ this -> createMock (AnyType::class );
100
+ $ variable = Query:: variable ( ' a ' );
101
+ $ list = Query:: list ([]) ;
102
+ $ predicate = Query:: boolean ( true );
101
103
102
104
$ single = Procedure::single ($ variable , $ list , $ predicate );
103
105
@@ -106,7 +108,7 @@ public function testSingle(): void
106
108
107
109
public function testPoint (): void
108
110
{
109
- $ map = new Map ([]);
111
+ $ map = Query:: map ([]);
110
112
111
113
$ point = Procedure::point ($ map );
112
114
@@ -115,7 +117,7 @@ public function testPoint(): void
115
117
116
118
public function testDate (): void
117
119
{
118
- $ value = $ this -> createMock (AnyType::class );
120
+ $ value = Query:: string ( " Hello World! " );
119
121
120
122
$ date = Procedure::date ($ value );
121
123
@@ -128,7 +130,7 @@ public function testDate(): void
128
130
129
131
public function testDateTime (): void
130
132
{
131
- $ value = $ this -> createMock (AnyType::class );
133
+ $ value = Query:: string ( " Hello World! " );
132
134
133
135
$ date = Procedure::datetime ($ value );
134
136
@@ -141,7 +143,7 @@ public function testDateTime(): void
141
143
142
144
public function testLocalDateTime (): void
143
145
{
144
- $ value = $ this -> createMock (AnyType::class );
146
+ $ value = Query:: string ( " Hello World! " );
145
147
146
148
$ date = Procedure::localdatetime ($ value );
147
149
@@ -154,7 +156,7 @@ public function testLocalDateTime(): void
154
156
155
157
public function testLocalTime (): void
156
158
{
157
- $ value = $ this -> createMock (AnyType::class );
159
+ $ value = Query:: string ( " Hello World! " );
158
160
159
161
$ date = Procedure::localtime ($ value );
160
162
@@ -167,7 +169,7 @@ public function testLocalTime(): void
167
169
168
170
public function testTime (): void
169
171
{
170
- $ value = $ this -> createMock (AnyType::class );
172
+ $ value = Query:: string ( " Hello World! " );
171
173
172
174
$ date = Procedure::time ($ value );
173
175
@@ -177,13 +179,4 @@ public function testTime(): void
177
179
178
180
$ this ->assertInstanceOf (Time::class, $ date );
179
181
}
180
-
181
- public function testToQuery (): void
182
- {
183
- $ mock = $ this ->getMockForAbstractClass (Procedure::class);
184
- $ mock ->method ('getSignature ' )->willReturn ('foo(%s) ' );
185
- $ mock ->method ('getParameters ' )->willReturn ([Literal::string ('bar ' )]);
186
-
187
- $ this ->assertSame ("foo('bar') " , $ mock ->toQuery ());
188
- }
189
182
}
0 commit comments