File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -66,15 +66,25 @@ public function fixWith(FixtureStrategyInterface $fixtureStrategy)
66
66
*/
67
67
public function run ()
68
68
{
69
+ $ errorList = [];
70
+
69
71
$ index = 0 ;
70
72
foreach ($ this ->strategyList as $ strategy ) {
71
73
try {
72
74
$ this ->doValidation ($ strategy );
73
75
} catch (\Exception $ exception ) {
74
- $ this ->applyFixtureStrategy ($ exception , $ index );
76
+ try {
77
+ $ this ->applyFixtureStrategy ($ exception , $ index );
78
+ } catch (\Exception $ afterFixtureException ){
79
+ $ errorList [] = $ afterFixtureException ->getMessage ();
80
+ }
75
81
}
76
82
$ index ++;
77
83
}
84
+
85
+ if (count ($ errorList ) > 0 ){
86
+ throw new \Exception (implode ("\n" , $ errorList ));
87
+ }
78
88
}
79
89
80
90
private function doValidation (ValidationStrategyInterface $ validationStrategy ): void
Original file line number Diff line number Diff line change @@ -257,4 +257,42 @@ public function testWhenValidationWithFixtureStrategyIsMadeThenValidationFailsAn
257
257
// assert
258
258
$ this ->assertSame ($ secondExceptionFromValidation , $ exceptionResult );
259
259
}
260
+
261
+ /**
262
+ *
263
+ */
264
+ public function testValidationWithTwoStrategiesThrowingOneExceptionForEach ()
265
+ {
266
+ // arrange
267
+
268
+ $ firstExceptionMessage = 'First exception ' ;
269
+ $ secondExceptionMessage = 'Second exception ' ;
270
+
271
+ $ firstException = new \Exception ($ firstExceptionMessage );
272
+ $ firstStrategy = $ this ->prepareValidationStrategyWithException ($ firstException );
273
+
274
+ $ secondException = new \Exception ($ secondExceptionMessage );
275
+ $ secondStrategy = $ this ->prepareValidationStrategyWithException ($ secondException );
276
+
277
+ $ subject = new TestEntity ();
278
+ $ factory = new ValidationFactory ();
279
+ $ exceptionResult = null ;
280
+
281
+ // act
282
+ try {
283
+ $ factory ->createFor ($ subject )
284
+ ->validateWith ($ firstStrategy )
285
+ ->validateWith ($ secondStrategy )
286
+ ->run ();
287
+ } catch (\Exception $ ex ){
288
+ $ exceptionResult = $ ex ;
289
+ }
290
+
291
+ // assert
292
+ $ this ->assertContains ($ firstExceptionMessage , $ exceptionResult ->getMessage ());
293
+ $ this ->assertContains ($ secondExceptionMessage , $ exceptionResult ->getMessage ());
294
+ var_dump ($ exceptionResult ->getMessage ());
295
+ }
296
+
297
+
260
298
}
You can’t perform that action at this time.
0 commit comments