@@ -304,6 +304,45 @@ public function testApplyWithEventDispatcher()
304
304
$ this ->assertSame ($ eventNameExpected , $ eventDispatcher ->dispatchedEvents );
305
305
}
306
306
307
+ public function testApplyDoesNotTriggerExtraGuardWithEventDispatcher ()
308
+ {
309
+ $ transitions [] = new Transition ('a-b ' , 'a ' , 'b ' );
310
+ $ transitions [] = new Transition ('a-c ' , 'a ' , 'c ' );
311
+ $ definition = new Definition (['a ' , 'b ' , 'c ' ], $ transitions );
312
+
313
+ $ subject = new \stdClass ();
314
+ $ subject ->marking = null ;
315
+ $ eventDispatcher = new EventDispatcherMock ();
316
+ $ workflow = new Workflow ($ definition , new MultipleStateMarkingStore (), $ eventDispatcher , 'workflow_name ' );
317
+
318
+ $ eventNameExpected = [
319
+ 'workflow.guard ' ,
320
+ 'workflow.workflow_name.guard ' ,
321
+ 'workflow.workflow_name.guard.a-b ' ,
322
+ 'workflow.leave ' ,
323
+ 'workflow.workflow_name.leave ' ,
324
+ 'workflow.workflow_name.leave.a ' ,
325
+ 'workflow.transition ' ,
326
+ 'workflow.workflow_name.transition ' ,
327
+ 'workflow.workflow_name.transition.a-b ' ,
328
+ 'workflow.enter ' ,
329
+ 'workflow.workflow_name.enter ' ,
330
+ 'workflow.workflow_name.enter.b ' ,
331
+ 'workflow.entered ' ,
332
+ 'workflow.workflow_name.entered ' ,
333
+ 'workflow.workflow_name.entered.b ' ,
334
+ 'workflow.completed ' ,
335
+ 'workflow.workflow_name.completed ' ,
336
+ 'workflow.workflow_name.completed.a-b ' ,
337
+ 'workflow.announce ' ,
338
+ 'workflow.workflow_name.announce ' ,
339
+ ];
340
+
341
+ $ marking = $ workflow ->apply ($ subject , 'a-b ' );
342
+
343
+ $ this ->assertSame ($ eventNameExpected , $ eventDispatcher ->dispatchedEvents );
344
+ }
345
+
307
346
public function testEventName ()
308
347
{
309
348
$ definition = $ this ->createComplexWorkflowDefinition ();
0 commit comments