Пример #1
0
 public function testStatusEqualsFails()
 {
     $item = new Item04();
     $item->sendToStatus('A');
     expect_not($item->statusEquals('B'));
     expect_not($item->statusEquals('Item04Workflow/B'));
     expect_not($item->statusEquals('NOTFOUND'));
     expect_not($item->statusEquals('Item04Workflow/NOTFOUND'));
     expect_not($item->statusEquals('NOTFOUND/NOTFOUND'));
     expect_not($item->statusEquals('invalid name'));
     expect_not($item->statusEquals(''));
     expect_not($item->statusEquals(null));
     $statusA = $item->getWorkflowStatus();
     $item->sendToStatus('B');
     verify($item->statusEquals('B'));
     expect_not($item->statusEquals($statusA));
 }
Пример #2
0
 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();
     });
 }
Пример #3
0
 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 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);
     });
 }