43
43
use Behat \Behat \Context \SnippetAcceptingContext ;
44
44
use Behatch \HttpCall \Request ;
45
45
use Doctrine \Common \Persistence \ManagerRegistry ;
46
- use Doctrine \Common \ Persistence \ ObjectManager ;
46
+ use Doctrine \ORM \ EntityManagerInterface ;
47
47
use Doctrine \ORM \Tools \SchemaTool ;
48
48
49
49
/**
50
50
* Defines application features from the specific context.
51
51
*/
52
- class FeatureContext implements Context, SnippetAcceptingContext
52
+ final class FeatureContext implements Context, SnippetAcceptingContext
53
53
{
54
- private $ doctrine ;
55
-
56
54
/**
57
- * @var ObjectManager
55
+ * @var EntityManagerInterface
58
56
*/
59
57
private $ manager ;
60
-
61
- /**
62
- * @var SchemaTool
63
- */
58
+ private $ doctrine ;
64
59
private $ schemaTool ;
65
-
66
- /**
67
- * @var array
68
- */
69
60
private $ classes ;
70
-
71
- /**
72
- * @var Request
73
- */
74
61
private $ request ;
75
62
76
63
/**
@@ -119,7 +106,7 @@ public function dropDatabase()
119
106
/**
120
107
* @Given there is :nb dummy objects
121
108
*/
122
- public function thereIsDummyObjects ($ nb )
109
+ public function thereIsDummyObjects (int $ nb )
123
110
{
124
111
$ descriptions = ['Smart dummy. ' , 'Not so smart dummy. ' ];
125
112
@@ -139,7 +126,7 @@ public function thereIsDummyObjects($nb)
139
126
/**
140
127
* @Given there are :nb foo objects with fake names
141
128
*/
142
- public function thereAreFooObjectsWithFakeNames ($ nb )
129
+ public function thereAreFooObjectsWithFakeNames (int $ nb )
143
130
{
144
131
$ names = ['Hawsepipe ' , 'Sthenelus ' , 'Ephesian ' , 'Separativeness ' , 'Balbo ' ];
145
132
$ bars = ['Lorem ' , 'Dolor ' , 'Dolor ' , 'Sit ' , 'Amet ' ];
@@ -158,7 +145,7 @@ public function thereAreFooObjectsWithFakeNames($nb)
158
145
/**
159
146
* @Given there is :nb dummy group objects
160
147
*/
161
- public function thereIsDummyGroupObjects ($ nb )
148
+ public function thereIsDummyGroupObjects (int $ nb )
162
149
{
163
150
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
164
151
$ dummyGroup = new DummyGroup ();
@@ -176,7 +163,7 @@ public function thereIsDummyGroupObjects($nb)
176
163
/**
177
164
* @Given there is :nb dummy property objects
178
165
*/
179
- public function thereIsDummyPropertyObjects ($ nb )
166
+ public function thereIsDummyPropertyObjects (int $ nb )
180
167
{
181
168
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
182
169
$ dummyProperty = new DummyProperty ();
@@ -198,7 +185,7 @@ public function thereIsDummyPropertyObjects($nb)
198
185
/**
199
186
* @Given there are :nb embedded dummy objects
200
187
*/
201
- public function thereIsEmbeddedDummyObjects ($ nb )
188
+ public function thereIsEmbeddedDummyObjects (int $ nb )
202
189
{
203
190
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
204
191
$ dummy = new EmbeddedDummy ();
@@ -217,7 +204,7 @@ public function thereIsEmbeddedDummyObjects($nb)
217
204
/**
218
205
* @Given there is :nb dummy objects with relatedDummy
219
206
*/
220
- public function thereIsDummyObjectsWithRelatedDummy ($ nb )
207
+ public function thereIsDummyObjectsWithRelatedDummy (int $ nb )
221
208
{
222
209
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
223
210
$ relatedDummy = new RelatedDummy ();
@@ -238,7 +225,7 @@ public function thereIsDummyObjectsWithRelatedDummy($nb)
238
225
/**
239
226
* @Given there is :nb dummy objects with embeddedDummy
240
227
*/
241
- public function thereIsDummyObjectsWithEmbeddedDummy ($ nb )
228
+ public function thereIsDummyObjectsWithEmbeddedDummy (int $ nb )
242
229
{
243
230
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
244
231
$ embeddableDummy = new EmbeddableDummy ();
@@ -257,7 +244,7 @@ public function thereIsDummyObjectsWithEmbeddedDummy($nb)
257
244
/**
258
245
* @Given there is :nb dummy objects having each :nbrelated relatedDummies
259
246
*/
260
- public function thereIsDummyObjectsWithRelatedDummies ($ nb , $ nbrelated )
247
+ public function thereIsDummyObjectsWithRelatedDummies (int $ nb , int $ nbrelated )
261
248
{
262
249
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
263
250
$ dummy = new Dummy ();
@@ -267,11 +254,12 @@ public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated)
267
254
for ($ j = 1 ; $ j <= $ nbrelated ; ++$ j ) {
268
255
$ relatedDummy = new RelatedDummy ();
269
256
$ relatedDummy ->setName ('RelatedDummy ' .$ j .$ i );
257
+
270
258
$ this ->manager ->persist ($ relatedDummy );
259
+
271
260
$ dummy ->addRelatedDummy ($ relatedDummy );
272
261
}
273
262
274
- $ this ->manager ->persist ($ relatedDummy );
275
263
$ this ->manager ->persist ($ dummy );
276
264
}
277
265
@@ -281,7 +269,7 @@ public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated)
281
269
/**
282
270
* @Given there is :nb dummy objects with dummyDate
283
271
*/
284
- public function thereIsDummyObjectsWithDummyDate ($ nb )
272
+ public function thereIsDummyObjectsWithDummyDate (int $ nb )
285
273
{
286
274
$ descriptions = ['Smart dummy. ' , 'Not so smart dummy. ' ];
287
275
@@ -307,7 +295,7 @@ public function thereIsDummyObjectsWithDummyDate($nb)
307
295
/**
308
296
* @Given there is :nb dummy objects with dummyDate and dummyBoolean :bool
309
297
*/
310
- public function thereIsDummyObjectsWithDummyDateAndDummyBoolean ($ nb , $ bool )
298
+ public function thereIsDummyObjectsWithDummyDateAndDummyBoolean (int $ nb , string $ bool )
311
299
{
312
300
$ descriptions = ['Smart dummy. ' , 'Not so smart dummy. ' ];
313
301
@@ -343,7 +331,7 @@ public function thereIsDummyObjectsWithDummyDateAndDummyBoolean($nb, $bool)
343
331
/**
344
332
* @Given there is :nb dummy objects with dummyDate and relatedDummy
345
333
*/
346
- public function thereIsDummyObjectsWithDummyDateAndRelatedDummy ($ nb )
334
+ public function thereIsDummyObjectsWithDummyDateAndRelatedDummy (int $ nb )
347
335
{
348
336
for ($ i = 1 ; $ i <= $ nb ; ++$ i ) {
349
337
$ date = new \DateTime (sprintf ('2015-04-%d ' , $ i ), new \DateTimeZone ('UTC ' ));
@@ -397,7 +385,7 @@ public function thereIsDummyObjectsWithDummyDateAndEmbeddedDummy($nb)
397
385
/**
398
386
* @Given there is :nb dummy objects with dummyPrice
399
387
*/
400
- public function thereIsDummyObjectsWithDummyPrice ($ nb )
388
+ public function thereIsDummyObjectsWithDummyPrice (int $ nb )
401
389
{
402
390
$ descriptions = ['Smart dummy. ' , 'Not so smart dummy. ' ];
403
391
$ prices = ['9.99 ' , '12.99 ' , '15.99 ' , '19.99 ' ];
@@ -418,7 +406,7 @@ public function thereIsDummyObjectsWithDummyPrice($nb)
418
406
/**
419
407
* @Given there is :nb dummy objects with dummyBoolean :bool
420
408
*/
421
- public function thereIsDummyObjectsWithDummyBoolean ($ nb , $ bool )
409
+ public function thereIsDummyObjectsWithDummyBoolean (int $ nb , string $ bool )
422
410
{
423
411
if (in_array ($ bool , ['true ' , '1 ' , 1 ], true )) {
424
412
$ bool = true ;
@@ -446,7 +434,7 @@ public function thereIsDummyObjectsWithDummyBoolean($nb, $bool)
446
434
/**
447
435
* @Given there is :nb embedded dummy objects with embeddedDummy.dummyBoolean :bool
448
436
*/
449
- public function thereIsDummyObjectsWithEmbeddedDummyBoolean ($ nb , $ bool )
437
+ public function thereIsDummyObjectsWithEmbeddedDummyBoolean (int $ nb , string $ bool )
450
438
{
451
439
if (in_array ($ bool , ['true ' , '1 ' , 1 ], true )) {
452
440
$ bool = true ;
@@ -473,7 +461,7 @@ public function thereIsDummyObjectsWithEmbeddedDummyBoolean($nb, $bool)
473
461
/**
474
462
* @Given there is :nb embedded dummy objects with relatedDummy.embeddedDummy.dummyBoolean :bool
475
463
*/
476
- public function thereIsDummyObjectsWithRelationEmbeddedDummyBoolean ($ nb , $ bool )
464
+ public function thereIsDummyObjectsWithRelationEmbeddedDummyBoolean (int $ nb , string $ bool )
477
465
{
478
466
if (in_array ($ bool , ['true ' , '1 ' , 1 ], true )) {
479
467
$ bool = true ;
@@ -593,7 +581,7 @@ public function thereIsAFooEntityWithRelatedBars()
593
581
/**
594
582
* @Given there is a RelatedDummy with :nb friends
595
583
*/
596
- public function thereIsARelatedDummyWithFriends ($ nb )
584
+ public function thereIsARelatedDummyWithFriends (int $ nb )
597
585
{
598
586
$ relatedDummy = new RelatedDummy ();
599
587
$ relatedDummy ->setName ('RelatedDummy with friends ' );
@@ -622,7 +610,7 @@ public function thereIsARelatedDummyWithFriends($nb)
622
610
}
623
611
624
612
/**
625
- * @Given there is an answer " :answer" to the question " :question"
613
+ * @Given there is an answer :answer to the question :question
626
614
*/
627
615
public function thereIsAnAnswerToTheQuestion (string $ a , string $ q )
628
616
{
@@ -643,7 +631,7 @@ public function thereIsAnAnswerToTheQuestion(string $a, string $q)
643
631
/**
644
632
* @Given there are :nb nodes in a container :uuid
645
633
*/
646
- public function thereAreNodesInAContainer ($ nb , $ uuid )
634
+ public function thereAreNodesInAContainer (int $ nb , string $ uuid )
647
635
{
648
636
$ container = new Container ();
649
637
$ container ->setId ($ uuid );
@@ -662,10 +650,9 @@ public function thereAreNodesInAContainer($nb, $uuid)
662
650
/**
663
651
* @Then the password :password for user :user should be hashed
664
652
*/
665
- public function thePasswordForUserShouldBeHashed ($ password , $ user )
653
+ public function thePasswordForUserShouldBeHashed (string $ password , string $ user )
666
654
{
667
- $ repository = $ this ->doctrine ->getRepository (User::class);
668
- $ user = $ repository ->find ($ user );
655
+ $ user = $ this ->doctrine ->getRepository (User::class)->find ($ user );
669
656
670
657
if (!password_verify ($ password , $ user ->getPassword ())) {
671
658
throw new \Exception ('User password mismatch ' );
0 commit comments