public function testEnterWorkflowFails1() { $item = new Item04(); $this->specify('enterWorkflow fails if the model is already in a workflow', function () use($item) { verify('current status is not set', $item->hasWorkflowStatus())->false(); $item->sendToStatus('Item04Workflow/A'); verify('current status is set', $item->hasWorkflowStatus())->true(); $this->setExpectedException('raoul2000\\workflow\\base\\WorkflowException', 'Model already in a workflow'); $item->enterWorkflow(); }); }
public function testEnterWorkflowFails1() { /** @var ActiveWorkflowBehavior $item */ $item = new Item04(); $this->specify('enterWorkflow fails if the model is already in a workflow', function () use($item) { verify('current status is not set', $item->hasWorkflowStatus())->false(); $item->sendToStatus('Item04Workflow/A'); verify('current status is set', $item->hasWorkflowStatus())->true(); $this->setExpectedException('fproject\\workflow\\core\\WorkflowException', 'Model already in a workflow'); $item->enterWorkflow(); }); }
public function testGetNextStatusOnEnter() { $item = new Item04(); $this->assertTrue($item->hasWorkflowStatus() == false); $this->specify('the initial status is returned as next status', function () use($item) { $n = $item->getNextStatuses(); expect('array is returned', is_array($n))->true(); expect('array has 1 items', count($n))->equals(1); expect('status Item04Workflow/A is returned as index', isset($n['Item04Workflow/A']))->true(); expect('status Item04Workflow/A is returned as Status', $n['Item04Workflow/A']['status']->getId())->equals('Item04Workflow/A'); verify('status returned is the initial status', $item->getWorkflowSource()->getWorkflow('Item04Workflow')->getInitialStatusId())->equals($n['Item04Workflow/A']['status']->getId()); }); }
public function testConvertionOnLeaveWorkflow() { $item = new Item04(); $item->attachBehavior('workflow', ['class' => SimpleWorkflowBehavior::className(), 'statusConverter' => 'converter']); $this->assertEquals(null, $item->status); $this->assertEquals('Item04Workflow/B', $item->getWorkflowStatus()->getId()); $this->specify('convertion is done when leaving workflow', function () use($item) { $item->sendToStatus(null); expect('item to not be in a workflow', $item->getWorkflow())->equals(null); expect('item to not have status', $item->hasWorkflowStatus())->false(); expect('status attribut to be converted into 55', $item->status)->equals(55); }); }
public function testGetNextStatusOnEnter() { /** @var Item04|ActiveWorkflowBehavior $item */ $item = new Item04(); $this->assertTrue($item->hasWorkflowStatus() == false); $this->specify('the initial status is returned as next status', function () use($item) { $n = $item->getNextStatuses(); expect('array is returned', is_array($n))->true(); expect('array has 1 items', count($n))->equals(1); expect('status Item04Workflow/A is returned as index', isset($n['Item04Workflow/A']))->true(); /** @var IStatus $sts */ $sts = $n['Item04Workflow/A']['status']; expect('status Item04Workflow/A is returned as Status', $sts->getId())->equals('Item04Workflow/A'); verify('status returned is the initial status', $item->getWorkflowFactory()->getWorkflow('Item04Workflow', $item)->getInitialStatusId())->equals($sts->getId()); }); }