11<?php namespace rdbms \unittest ;
22
33use lang \IllegalArgumentException ;
4- use rdbms \{Criteria , DriverManager , SQLStateException };
54use rdbms \criterion \Restrictions ;
65use rdbms \unittest \dataset \Job ;
7- use unittest \TestCase ;
6+ use rdbms \unittest \mock \RegisterMockConnection ;
7+ use rdbms \{Criteria , DriverManager , SQLStateException };
8+ use unittest \{Expect , Test , TestCase };
89
910/**
1011 * Test criteria class
1112 *
1213 * @see xp://rdbms.Criteria
1314 */
14- #[@action( new \ rdbms \ unittest \ mock \ RegisterMockConnection ())]
15+ #[Action(eval: ' new RegisterMockConnection() ' )]
1516class CriteriaTest extends TestCase {
1617 public $ conn = null ;
1718 public $ peer = null ;
@@ -37,23 +38,23 @@ protected function assertSql($sql, $criteria) {
3738 $ this ->assertEquals ($ sql , trim ($ criteria ->toSQL ($ this ->conn , $ this ->peer ), ' ' ));
3839 }
3940
40- #[@test ]
41+ #[Test ]
4142 public function emptyCriteria () {
4243 $ this ->assertSql ('' , new Criteria ());
4344 }
4445
45- #[@test ]
46+ #[Test ]
4647 public function simpleCriteria () {
4748 $ this ->assertSql ('where job_id = 1 ' , new Criteria (['job_id ' , 1 , EQUAL ]));
4849 }
4950
50- #[@test, @expect (IllegalArgumentException::class)]
51+ #[Test, Expect (IllegalArgumentException::class)]
5152 public function nonExistantFieldCausesException () {
5253 $ criteria = new Criteria (['non-existant-field ' , 1 , EQUAL ]);
5354 $ criteria ->toSQL ($ this ->conn , $ this ->peer );
5455 }
5556
56- #[@test ]
57+ #[Test ]
5758 public function complexCriteria () {
5859 with ($ c = new Criteria ()); {
5960 $ c ->add ('job_id ' , 1 , EQUAL );
@@ -68,87 +69,87 @@ public function complexCriteria() {
6869 );
6970 }
7071
71- #[@test ]
72+ #[Test ]
7273 public function inCriteria () {
7374 $ c = new Criteria ();
7475 $ c ->add ('job_id ' , [1 , 2 ], IN );
7576
7677 $ this ->assertSql ('where job_id in (1, 2) ' , $ c );
7778 }
7879
79- #[@test ]
80+ #[Test ]
8081 public function notInCriteria () {
8182 $ c = new Criteria ();
8283 $ c ->add ('job_id ' , [1 , 2 ], NOT_IN );
8384
8485 $ this ->assertSql ('where job_id not in (1, 2) ' , $ c );
8586 }
8687
87- #[@test ]
88+ #[Test ]
8889 public function likeCriteria () {
8990 $ c = new Criteria ();
9091 $ c ->add ('title ' , '%keyword% ' , LIKE );
9192
9293 $ this ->assertSql ('where title like "%keyword%" ' , $ c );
9394 }
9495
95- #[@test ]
96+ #[Test ]
9697 public function equalCriteria () {
9798 $ c = new Criteria ();
9899 $ c ->add ('job_id ' , 1 , EQUAL );
99100
100101 $ this ->assertSql ('where job_id = 1 ' , $ c );
101102 }
102103
103- #[@test ]
104+ #[Test ]
104105 public function notEqualCriteria () {
105106 $ c = new Criteria ();
106107 $ c ->add ('job_id ' , 1 , NOT_EQUAL );
107108
108109 $ this ->assertSql ('where job_id != 1 ' , $ c );
109110 }
110111
111- #[@test ]
112+ #[Test ]
112113 public function lessThanCriteria () {
113114 $ c = new Criteria ();
114115 $ c ->add ('job_id ' , 100 , LESS_THAN );
115116
116117 $ this ->assertSql ('where job_id < 100 ' , $ c );
117118 }
118119
119- #[@test ]
120+ #[Test ]
120121 public function greaterThanCriteria () {
121122 $ c = new Criteria ();
122123 $ c ->add ('job_id ' , 100 , GREATER_THAN );
123124
124125 $ this ->assertSql ('where job_id > 100 ' , $ c );
125126 }
126127
127- #[@test ]
128+ #[Test ]
128129 public function lessEqualCriteria () {
129130 $ c = new Criteria ();
130131 $ c ->add ('job_id ' , 100 , LESS_EQUAL );
131132
132133 $ this ->assertSql ('where job_id <= 100 ' , $ c );
133134 }
134135
135- #[@test ]
136+ #[Test ]
136137 public function greaterEqualCriteria () {
137138 $ c = new Criteria ();
138139 $ c ->add ('job_id ' , 100 , GREATER_EQUAL );
139140
140141 $ this ->assertSql ('where job_id >= 100 ' , $ c );
141142 }
142143
143- #[@test ]
144+ #[Test ]
144145 public function bitAndCriteria () {
145146 $ c = new Criteria ();
146147 $ c ->add ('job_id ' , 100 , BIT_AND );
147148
148149 $ this ->assertSql ('where job_id & 100 != 0 ' , $ c );
149150 }
150151
151- #[@test ]
152+ #[Test ]
152153 public function restrictionsFactory () {
153154 $ job_id = Job::column ('job_id ' );
154155 $ c = new Criteria (Restrictions::anyOf (
@@ -173,30 +174,30 @@ public function restrictionsFactory() {
173174 );
174175 }
175176
176- #[@test ]
177+ #[Test ]
177178 public function constructorAcceptsVarArgArrays () {
178179 $ this ->assertSql (
179180 'where job_id = 1 and title = "Hello" ' ,
180181 new Criteria (['job_id ' , 1 , EQUAL ], ['title ' , 'Hello ' , EQUAL ])
181182 );
182183 }
183184
184- #[@test ]
185+ #[Test ]
185186 public function addReturnsThis () {
186187 $ this ->assertInstanceOf (Criteria::class, (new Criteria ())->add ('job_id ' , 1 , EQUAL ));
187188 }
188189
189- #[@test ]
190+ #[Test ]
190191 public function addOrderByReturnsThis () {
191192 $ this ->assertInstanceOf (Criteria::class, (new Criteria ())->add ('job_id ' , 1 , EQUAL )->addOrderBy ('valid_from ' , DESCENDING ));
192193 }
193194
194- #[@test ]
195+ #[Test ]
195196 public function addGroupByReturnsThis () {
196197 $ this ->assertInstanceOf (Criteria::class, (new Criteria ())->add ('job_id ' , 1 , EQUAL )->addGroupBy ('valid_from ' ));
197198 }
198199
199- #[@test ]
200+ #[Test ]
200201 public function addOrderByColumn () {
201202 with ($ c = new Criteria ()); {
202203 $ c ->addOrderBy (Job::column ('valid_from ' ));
@@ -208,7 +209,7 @@ public function addOrderByColumn() {
208209 );
209210 }
210211
211- #[@test ]
212+ #[Test ]
212213 public function addOrderByString () {
213214 with ($ c = new Criteria ()); {
214215 $ c ->addOrderBy ("valid_from " );
@@ -220,7 +221,7 @@ public function addOrderByString() {
220221 );
221222 }
222223
223- #[@test ]
224+ #[Test ]
224225 public function addGroupByColumn () {
225226 with ($ c = new Criteria ()); {
226227 $ c ->addGroupBy (Job::column ('valid_from ' ));
@@ -232,7 +233,7 @@ public function addGroupByColumn() {
232233 );
233234 }
234235
235- #[@test ]
236+ #[Test ]
236237 public function addGroupByString () {
237238 with ($ c = new Criteria ()); {
238239 $ c ->addGroupBy ("valid_from " );
@@ -244,22 +245,22 @@ public function addGroupByString() {
244245 );
245246 }
246247
247- #[@test, @expect (IllegalArgumentException::class)]
248+ #[Test, Expect (IllegalArgumentException::class)]
248249 public function createNonExistantColumn () {
249250 Job::column ('not_existant ' );
250251 }
251252
252- #[@test, @expect (SQLStateException::class)]
253+ #[Test, Expect (SQLStateException::class)]
253254 public function addGroupByNonExistantColumnString () {
254255 (new Criteria ())->addGroupBy ('not_existant ' )->toSQL ($ this ->conn , $ this ->peer );
255256 }
256257
257- #[@test ]
258+ #[Test ]
258259 public function fetchModeChaining () {
259260 $ this ->assertInstanceOf (Criteria::class, (new Criteria ())->setFetchmode (\rdbms \join \Fetchmode::join ('PersonJob ' )));
260261 }
261262
262- #[@test ]
263+ #[Test ]
263264 public function testIsJoin () {
264265 $ crit = new Criteria ();
265266 $ this ->assertFalse ($ crit ->isJoin ());
@@ -269,7 +270,7 @@ public function testIsJoin() {
269270 $ this ->assertFalse ($ crit ->setFetchmode (\rdbms \join \Fetchmode::select ('PersonJob ' ))->isJoin ());
270271 }
271272
272- #[@test ]
273+ #[Test ]
273274 public function testJoinWithoutCondition () {
274275 $ jp = new \rdbms \join \JoinProcessor (Job::getPeer ());
275276 $ jp ->setFetchModes (['PersonJob->Department ' => 'join ' ]);
@@ -283,7 +284,7 @@ public function testJoinWithoutCondition() {
283284 $ jp ->leaveJoinContext ();
284285 }
285286
286- #[@test ]
287+ #[Test ]
287288 public function testJoinWithCondition () {
288289 $ jp = new \rdbms \join \JoinProcessor (Job::getPeer ());
289290 $ jp ->setFetchModes (['PersonJob->Department ' => 'join ' ]);
@@ -299,7 +300,7 @@ public function testJoinWithCondition() {
299300 $ jp ->leaveJoinContext ();
300301 }
301302
302- #[@test ]
303+ #[Test ]
303304 public function testJoinWithProjection () {
304305 $ jp = new \rdbms \join \JoinProcessor (Job::getPeer ());
305306 $ jp ->setFetchModes (['PersonJob->Department ' => 'join ' ]);
0 commit comments