public function testEquals_03() { $n = new SWNode('node1', 'w1'); try { $n->equals(''); $this->fail(); } catch (SWException $e) { $this->assertEquals($e->getCode(), SWException::SW_ERR_CREATE_NODE); } try { $n->equals(null); $this->fail(); } catch (SWException $e) { $this->assertEquals($e->getCode(), SWException::SW_ERR_CREATE_NODE); } }
/** * */ public function testTransitionTask_01() { $n = new SWNode(array('id' => 'node1', 'transition' => 'node2,node1'), 'w1'); $this->assertTrue($n->equals('w1/node1')); $this->assertTrue($n->getTransitionTask(new SWNode('node2', 'w1')) == null); $this->assertTrue($n->getTransitionTask(new SWNode('node1', 'w1')) == null); $this->assertTrue($n->getTransitionTask(new SWNode('node3', 'w1')) == null); }
public function testNextNodeIds_06() { $n = new SWNode(array('id' => 'w1/node1', 'transition' => array('node1' => 'task1', 'w2/node2' => 'task2', 'node3'))); $this->assertTrue($n->equals('w1/node1')); $next = $n->getNextNodeIds(); $this->assertEquals(count($next), 3); $this->assertTrue(in_array('w1/node1', $next)); $this->assertTrue(in_array('w2/node2', $next)); $this->assertTrue(in_array('w1/node3', $next)); }
/** * SWnode comparator method. Note that only the node and the workflow id * members are compared. * * @param mixed SWNode object or string. If a string is provided it is used to create * a new SWNode object. */ public function equals($status) { if ($status instanceof SWNode) { return $status->toString() == $this->toString(); } else { try { $other = new SWNode($status, $this->getWorkflowId()); return $other->equals($this); } catch (Exception $e) { throw new SWException('comparaison error - the value passed as argument (value=' . $status . ') cannot be converted into a SWNode', $e->getCode()); } } }
/** * */ public function equals($status) { if (is_a($status, 'SWnode') and $status->getWorkflowId() == $this->getWorkflowId() and $status->getId() == $this->getId()) { return true; } elseif (is_string($status) and !empty($status)) { $other = new SWNode($status, $this->getWorkflowId()); return $other->equals($this); } else { return false; } }