Exemplo n.º 1
0
 /**
  * http://www.yiiframework.com/forum/index.php/topic/12071-extension-simpleworkflow/page__view__findpost__p__164472
  */
 public function testInitialisation1_bis()
 {
     $m = new Model01();
     $this->assertEquals($m->swGetWorkflowId(), 'workflow1');
     $this->assertEquals($m->swGetDefaultWorkflowId(), 'workflow1');
     $this->assertTrue($m->swHasStatus());
     $this->assertTrue($m->save());
 }
Exemplo n.º 2
0
 /**
  *
  */
 public function testInitialisation1()
 {
     $m = Model01::model()->findByPk('1');
     $this->assertTrue($m->swHasStatus());
     $m->swNextStatus('S2');
     $this->assertEquals($m->swGetWorkflowId(), 'workflow1');
     $this->assertEquals($m->swGetDefaultWorkflowId(), 'workflow1');
     $this->assertTrue($m->swHasStatus());
     $this->assertEquals($m->swGetStatus()->toString(), 'workflow1/S2');
     $this->assertTrue($m->swGetStatus()->equals('S2'));
     $this->assertFalse($m->swGetStatus()->equals('s2'));
     $continue = true;
     try {
         $m->swNextStatus('S3');
         $continue = false;
     } catch (Exception $e) {
         $this->assertEquals($e->getCode(), SWException::SW_ERR_STATUS_UNREACHABLE);
     }
     $this->assertTrue($continue);
     $m->swNextStatus('S4');
     $this->assertTrue($m->swGetStatus()->equals('S4'));
     $m->swNextStatus('S5');
     $this->assertTrue($m->swGetStatus()->equals('S5'));
     $this->assertTrue($m->swIsFinalStatus());
 }
Exemplo n.º 3
0
 /**
  *
  */
 public function test1()
 {
     $m = new Model0F();
     $this->assertTrue($m->swNextStatus(SWWorkflow1::S1));
     $this->assertTrue($m->taskCallCount == 0);
     $this->assertTrue($m->swGetStatus()->equals(SWWorkflow1::S1));
     $this->assertTrue($m->swStatusEquals(SWWorkflow1::S1));
     $this->assertTrue($m->save());
     $this->assertTrue($m->taskCallCount == 0);
     $m->status = SWWorkflow1::S2;
     $m->update(array('status'));
     $this->assertTrue($m->taskCallCount == 1);
     $this->assertTrue($m->swGetStatus()->equals(SWWorkflow1::S2));
     $this->assertTrue($m->swStatusEquals(SWWorkflow1::S2));
     $m = Model01::model()->findByPk('1');
     $this->assertEquals($m->swGetWorkflowId(), 'workflow1');
     $this->assertEquals($m->swGetDefaultWorkflowId(), 'workflow1');
     $this->assertTrue($m->swHasStatus());
     $this->assertTrue($m->swIsInitialStatus($m->swGetStatus()));
     $this->assertTrue($m->swIsInitialStatus('workflow1/S1'));
     $this->assertTrue($m->swIsInitialStatus('S1'));
     $this->assertTrue($m->swIsInitialStatus());
     $this->assertEquals($m->swGetStatus()->toString(), 'workflow1/S1');
     $this->assertEquals(count($m->swGetAllStatus()), 5);
     $this->assertEquals($m->swIsEventEnabled(), false);
 }
Exemplo n.º 4
0
 /**
  *
  *
  */
 public function testInitialisation2()
 {
     $m = Model01::model()->findByPk('2');
     $this->assertEquals($m->swGetWorkflowId(), 'workflow1');
     $this->assertEquals($m->swGetDefaultWorkflowId(), 'workflow1');
     $this->assertTrue($m->swHasStatus());
     $this->assertEquals($m->swGetStatus()->toString(), 'workflow1/S2');
     $this->assertFalse($m->swIsInitialStatus($m->swGetStatus()));
     $this->assertFalse($m->swIsInitialStatus('workflow1/S2'));
     $this->assertTrue($m->swIsInitialStatus('S1'));
     $this->assertFalse($m->swIsInitialStatus());
     $this->assertEquals(count($m->swGetAllStatus()), 5);
     $this->assertEquals($m->swIsEventEnabled(), false);
 }