コード例 #1
0
 public function testItWorks()
 {
     $definition = $this->createSimpleWorkflowDefinition();
     $object = new \stdClass();
     $object->marking = null;
     $logger = new Logger();
     $ed = new EventDispatcher();
     $ed->addSubscriber(new AuditTrailListener($logger));
     $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $ed);
     $workflow->apply($object, 't1');
     $expected = array('Leaving "a" for subject of class "stdClass".', 'Transition "t1" for subject of class "stdClass".', 'Entering "b" for subject of class "stdClass".');
     $this->assertSame($expected, $logger->logs);
 }
コード例 #2
0
 public function testItWorks()
 {
     $transitions = array(new Transition('t1', 'a', 'b'), new Transition('t2', 'a', 'b'));
     $definition = new Definition(array('a', 'b'), $transitions);
     $object = new \stdClass();
     $object->marking = null;
     $logger = new Logger();
     $ed = new EventDispatcher();
     $ed->addSubscriber(new AuditTrailListener($logger));
     $workflow = new Workflow($definition, new PropertyAccessorMarkingStore(), $ed);
     $workflow->apply($object, 't1');
     $expected = array('Leaving "a" for subject of class "stdClass".', 'Transition "t1" for subject of class "stdClass".', 'Entering "b" for subject of class "stdClass".');
     $this->assertSame($expected, $logger->logs);
 }
コード例 #3
0
ファイル: WorkflowTest.php プロジェクト: ayoah/symfony
 public function testApplyWithEventDispatcher()
 {
     $definition = $this->createComplexWorkflow();
     $subject = new \stdClass();
     $subject->marking = null;
     $eventDispatcher = new EventDispatcherMock();
     $workflow = new Workflow($definition, new PropertyAccessorMarkingStore(), $eventDispatcher, 'workflow_name');
     $eventNameExpected = array('workflow.guard', 'workflow.workflow_name.guard', 'workflow.workflow_name.guard.t1', 'workflow.leave', 'workflow.workflow_name.leave', 'workflow.workflow_name.leave.a', 'workflow.transition', 'workflow.workflow_name.transition', 'workflow.workflow_name.transition.t1', 'workflow.enter', 'workflow.workflow_name.enter', 'workflow.workflow_name.enter.b', 'workflow.workflow_name.enter.c', 'workflow.guard', 'workflow.workflow_name.guard', 'workflow.workflow_name.guard.t2', 'workflow.workflow_name.announce.t2');
     $marking = $workflow->apply($subject, 't1');
     $this->assertSame($eventNameExpected, $eventDispatcher->dispatchedEvents);
 }