45
45
use Behat \Behat \Context \SnippetAcceptingContext ;
46
46
use Behatch \HttpCall \Request ;
47
47
use Doctrine \Common \Persistence \ManagerRegistry ;
48
- use Doctrine \Common \ Persistence \ ObjectManager ;
48
+ use Doctrine \ORM \ EntityManagerInterface ;
49
49
use Doctrine \ORM \Tools \SchemaTool ;
50
50
51
51
/**
52
52
* Defines application features from the specific context.
53
53
*/
54
- class FeatureContext implements Context, SnippetAcceptingContext
54
+ final class FeatureContext implements Context, SnippetAcceptingContext
55
55
{
56
- private $ doctrine ;
57
-
58
56
/**
59
- * @var ObjectManager
57
+ * @var EntityManagerInterface
60
58
*/
61
59
private $ manager ;
62
-
63
- /**
64
- * @var SchemaTool
65
- */
60
+ private $ doctrine ;
66
61
private $ schemaTool ;
67
-
68
- /**
69
- * @var array
70
- */
71
62
private $ classes ;
72
-
73
- /**
74
- * @var Request
75
- */
76
63
private $ request ;
77
64
78
65
/**
@@ -121,7 +108,7 @@ public function dropDatabase()
121
108
/**
122
109
* @Given there is :nb dummy objects
123
110
*/
124
- public function thereIsDummyObjects ($ nb )
111
+ public function thereIsDummyObjects (int $ nb )
125
112
{
126
113
$ descriptions = ['Smart dummy. ' , 'Not so smart dummy. ' ];
127
114
@@ -141,7 +128,7 @@ public function thereIsDummyObjects($nb)
141
128
/**
142
129
* @Given there are :nb foo objects with fake names
143
130
*/
144
- public function thereAreFooObjectsWithFakeNames ($ nb )
131
+ public function thereAreFooObjectsWithFakeNames (int $ nb )
145
132
{
146
133
$ names = ['Hawsepipe ' , 'Sthenelus ' , 'Ephesian ' , 'Separativeness ' , 'Balbo ' ];
147
134
$ bars = ['Lorem ' , 'Dolor ' , 'Dolor ' , 'Sit ' , 'Amet ' ];
@@ -160,7 +147,7 @@ public function thereAreFooObjectsWithFakeNames($nb)
160
147
/**
161
148
* @Given there is :nb dummy group objects
162
149
*/
163
- public function thereIsDummyGroupObjects ($ nb )
150
+ public function thereIsDummyGroupObjects (int $ nb )
164
151
{
165
152
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
166
153
$ dummyGroup = new DummyGroup ();
@@ -178,7 +165,7 @@ public function thereIsDummyGroupObjects($nb)
178
165
/**
179
166
* @Given there is :nb dummy property objects
180
167
*/
181
- public function thereIsDummyPropertyObjects ($ nb )
168
+ public function thereIsDummyPropertyObjects (int $ nb )
182
169
{
183
170
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
184
171
$ dummyProperty = new DummyProperty ();
@@ -200,7 +187,7 @@ public function thereIsDummyPropertyObjects($nb)
200
187
/**
201
188
* @Given there are :nb embedded dummy objects
202
189
*/
203
- public function thereIsEmbeddedDummyObjects ($ nb )
190
+ public function thereIsEmbeddedDummyObjects (int $ nb )
204
191
{
205
192
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
206
193
$ dummy = new EmbeddedDummy ();
@@ -219,7 +206,7 @@ public function thereIsEmbeddedDummyObjects($nb)
219
206
/**
220
207
* @Given there is :nb dummy objects with relatedDummy
221
208
*/
222
- public function thereIsDummyObjectsWithRelatedDummy ($ nb )
209
+ public function thereIsDummyObjectsWithRelatedDummy (int $ nb )
223
210
{
224
211
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
225
212
$ relatedDummy = new RelatedDummy ();
@@ -240,7 +227,7 @@ public function thereIsDummyObjectsWithRelatedDummy($nb)
240
227
/**
241
228
* @Given there is :nb dummy objects with relatedDummy and its thirdLevel
242
229
*/
243
- public function thereIsDummyObjectsWithRelatedDummyAndItsThirdLevel ($ nb )
230
+ public function thereIsDummyObjectsWithRelatedDummyAndItsThirdLevel (int $ nb )
244
231
{
245
232
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
246
233
$ thirdLevel = new ThirdLevel ();
@@ -265,7 +252,7 @@ public function thereIsDummyObjectsWithRelatedDummyAndItsThirdLevel($nb)
265
252
/**
266
253
* @Given there is :nb dummy objects with embeddedDummy
267
254
*/
268
- public function thereIsDummyObjectsWithEmbeddedDummy ($ nb )
255
+ public function thereIsDummyObjectsWithEmbeddedDummy (int $ nb )
269
256
{
270
257
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
271
258
$ embeddableDummy = new EmbeddableDummy ();
@@ -284,7 +271,7 @@ public function thereIsDummyObjectsWithEmbeddedDummy($nb)
284
271
/**
285
272
* @Given there is :nb dummy objects having each :nbrelated relatedDummies
286
273
*/
287
- public function thereIsDummyObjectsWithRelatedDummies ($ nb , $ nbrelated )
274
+ public function thereIsDummyObjectsWithRelatedDummies (int $ nb , int $ nbrelated )
288
275
{
289
276
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
290
277
$ dummy = new Dummy ();
@@ -294,11 +281,12 @@ public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated)
294
281
for ($ j = 1 ; $ j <= $ nbrelated ; ++$ j ) {
295
282
$ relatedDummy = new RelatedDummy ();
296
283
$ relatedDummy ->setName ('RelatedDummy ' .$ j .$ i );
284
+
297
285
$ this ->manager ->persist ($ relatedDummy );
286
+
298
287
$ dummy ->addRelatedDummy ($ relatedDummy );
299
288
}
300
289
301
- $ this ->manager ->persist ($ relatedDummy );
302
290
$ this ->manager ->persist ($ dummy );
303
291
}
304
292
@@ -308,7 +296,7 @@ public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated)
308
296
/**
309
297
* @Given there is :nb dummy objects with dummyDate
310
298
*/
311
- public function thereIsDummyObjectsWithDummyDate ($ nb )
299
+ public function thereIsDummyObjectsWithDummyDate (int $ nb )
312
300
{
313
301
$ descriptions = ['Smart dummy. ' , 'Not so smart dummy. ' ];
314
302
@@ -334,7 +322,7 @@ public function thereIsDummyObjectsWithDummyDate($nb)
334
322
/**
335
323
* @Given there is :nb dummy objects with dummyDate and dummyBoolean :bool
336
324
*/
337
- public function thereIsDummyObjectsWithDummyDateAndDummyBoolean ($ nb , $ bool )
325
+ public function thereIsDummyObjectsWithDummyDateAndDummyBoolean (int $ nb , string $ bool )
338
326
{
339
327
$ descriptions = ['Smart dummy. ' , 'Not so smart dummy. ' ];
340
328
@@ -370,7 +358,7 @@ public function thereIsDummyObjectsWithDummyDateAndDummyBoolean($nb, $bool)
370
358
/**
371
359
* @Given there is :nb dummy objects with dummyDate and relatedDummy
372
360
*/
373
- public function thereIsDummyObjectsWithDummyDateAndRelatedDummy ($ nb )
361
+ public function thereIsDummyObjectsWithDummyDateAndRelatedDummy (int $ nb )
374
362
{
375
363
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
376
364
$ date = new \DateTime (sprintf ('2015-04-%d ' , $ i ), new \DateTimeZone ('UTC ' ));
@@ -398,7 +386,7 @@ public function thereIsDummyObjectsWithDummyDateAndRelatedDummy($nb)
398
386
/**
399
387
* @Given there is :nb embedded dummy objects with dummyDate and embeddedDummy
400
388
*/
401
- public function thereIsDummyObjectsWithDummyDateAndEmbeddedDummy ($ nb )
389
+ public function thereIsDummyObjectsWithDummyDateAndEmbeddedDummy (int $ nb )
402
390
{
403
391
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
404
392
$ date = new \DateTime (sprintf ('2015-04-%d ' , $ i ), new \DateTimeZone ('UTC ' ));
@@ -424,7 +412,7 @@ public function thereIsDummyObjectsWithDummyDateAndEmbeddedDummy($nb)
424
412
/**
425
413
* @Given there is :nb dummy objects with dummyPrice
426
414
*/
427
- public function thereIsDummyObjectsWithDummyPrice ($ nb )
415
+ public function thereIsDummyObjectsWithDummyPrice (int $ nb )
428
416
{
429
417
$ descriptions = ['Smart dummy. ' , 'Not so smart dummy. ' ];
430
418
$ prices = ['9.99 ' , '12.99 ' , '15.99 ' , '19.99 ' ];
@@ -445,7 +433,7 @@ public function thereIsDummyObjectsWithDummyPrice($nb)
445
433
/**
446
434
* @Given there is :nb dummy objects with dummyBoolean :bool
447
435
*/
448
- public function thereIsDummyObjectsWithDummyBoolean ($ nb , $ bool )
436
+ public function thereIsDummyObjectsWithDummyBoolean (int $ nb , string $ bool )
449
437
{
450
438
if (in_array ($ bool , ['true ' , '1 ' , 1 ], true )) {
451
439
$ bool = true ;
@@ -473,7 +461,7 @@ public function thereIsDummyObjectsWithDummyBoolean($nb, $bool)
473
461
/**
474
462
* @Given there is :nb embedded dummy objects with embeddedDummy.dummyBoolean :bool
475
463
*/
476
- public function thereIsDummyObjectsWithEmbeddedDummyBoolean ($ nb , $ bool )
464
+ public function thereIsDummyObjectsWithEmbeddedDummyBoolean (int $ nb , string $ bool )
477
465
{
478
466
if (in_array ($ bool , ['true ' , '1 ' , 1 ], true )) {
479
467
$ bool = true ;
@@ -500,7 +488,7 @@ public function thereIsDummyObjectsWithEmbeddedDummyBoolean($nb, $bool)
500
488
/**
501
489
* @Given there is :nb embedded dummy objects with relatedDummy.embeddedDummy.dummyBoolean :bool
502
490
*/
503
- public function thereIsDummyObjectsWithRelationEmbeddedDummyBoolean ($ nb , $ bool )
491
+ public function thereIsDummyObjectsWithRelationEmbeddedDummyBoolean (int $ nb , string $ bool )
504
492
{
505
493
if (in_array ($ bool , ['true ' , '1 ' , 1 ], true )) {
506
494
$ bool = true ;
@@ -640,7 +628,7 @@ public function thereIsAFooEntityWithRelatedBars()
640
628
/**
641
629
* @Given there is a RelatedDummy with :nb friends
642
630
*/
643
- public function thereIsARelatedDummyWithFriends ($ nb )
631
+ public function thereIsARelatedDummyWithFriends (int $ nb )
644
632
{
645
633
$ relatedDummy = new RelatedDummy ();
646
634
$ relatedDummy ->setName ('RelatedDummy with friends ' );
@@ -669,7 +657,7 @@ public function thereIsARelatedDummyWithFriends($nb)
669
657
}
670
658
671
659
/**
672
- * @Given there is an answer " :answer" to the question " :question"
660
+ * @Given there is an answer :answer to the question :question
673
661
*/
674
662
public function thereIsAnAnswerToTheQuestion (string $ a , string $ q )
675
663
{
@@ -690,7 +678,7 @@ public function thereIsAnAnswerToTheQuestion(string $a, string $q)
690
678
/**
691
679
* @Given there are :nb nodes in a container :uuid
692
680
*/
693
- public function thereAreNodesInAContainer ($ nb , $ uuid )
681
+ public function thereAreNodesInAContainer (int $ nb , string $ uuid )
694
682
{
695
683
$ container = new Container ();
696
684
$ container ->setId ($ uuid );
@@ -709,10 +697,9 @@ public function thereAreNodesInAContainer($nb, $uuid)
709
697
/**
710
698
* @Then the password :password for user :user should be hashed
711
699
*/
712
- public function thePasswordForUserShouldBeHashed ($ password , $ user )
700
+ public function thePasswordForUserShouldBeHashed (string $ password , string $ user )
713
701
{
714
- $ repository = $ this ->doctrine ->getRepository (User::class);
715
- $ user = $ repository ->find ($ user );
702
+ $ user = $ this ->doctrine ->getRepository (User::class)->find ($ user );
716
703
717
704
if (!password_verify ($ password , $ user ->getPassword ())) {
718
705
throw new \Exception ('User password mismatch ' );
0 commit comments