コード例 #1
0
 protected function setup()
 {
     parent::setUp();
     Yii::$app->set('workflowFactory', ['class' => 'fproject\\workflow\\core\\ArrayWorkflowItemFactory', 'workflowSourceNamespace' => 'tests\\codeception\\unit\\models']);
     Item06Behavior::$maxPostCount = 2;
     Item06Behavior::$countPost = 0;
     Item06Behavior::$countPostToCorrect = 0;
     Item06Behavior::$countPostCorrected = 0;
 }
コード例 #2
0
 public function testLeaveNewOnDelete()
 {
     $post = new Item06();
     $post->name = 'post name';
     $post->enterWorkflow();
     verify($post->save())->true();
     verify($post->getWorkflowStatus()->getId())->equals('Item06Workflow/new');
     $post->canLeaveWorkflow(true);
     Item06Behavior::$countBeforeLeaveNew = 0;
     Item06Behavior::$countAfterLeaveNew = 0;
     expect_that($post->delete());
     expect('the beforeLeaveNew has been called once', Item06Behavior::$countBeforeLeaveNew)->equals(1);
     expect('the afterLeaveNew has been called once', Item06Behavior::$countAfterLeaveNew)->equals(1);
 }
コード例 #3
0
 public function testLeaveWorkflowOnDelete()
 {
     $post = new Item06();
     $post->name = 'post name';
     $post->enterWorkflow();
     verify($post->save())->true();
     verify($post->getWorkflowStatus()->getId())->equals('Item06Workflow/new');
     Item06Behavior::$countLeaveWorkflow = 0;
     $post->canLeaveWorkflow(true);
     expect_that($post->delete());
     verify(Item06Behavior::$countLeaveWorkflow)->equals(1);
     $post = new Item06();
     $post->name = 'post name';
     $post->enterWorkflow();
     verify($post->save())->true();
     verify($post->getWorkflowStatus()->getId())->equals('Item06Workflow/new');
     $post->canLeaveWorkflow(false);
     // refuse leave workflow
     // Now, the handler attached to the beforeLeaveWorkflow Event (see Item06Behavior)
     // will invalidate the event and return false (preventing the DELETE operation)
     expect_not($post->delete());
 }
コード例 #4
0
ファイル: Item06.php プロジェクト: raoul2000/yii2-workflow
 public function behaviors()
 {
     return ['workflow' => ['class' => SimpleWorkflowBehavior::className()], 'activeWorkflow' => ['class' => Item06Behavior::className()]];
 }