/** * Probes equivalence of itself against an other node and collects all * errors in the passed {@link Notification} object. * * @param Node $other Node to compare against. * @param Notification $result Object which collects all equivlanece violations. * * @return void */ public function probeEquivalence(Node $other, Notification $result) { if (!$other instanceof Terminal) { $result->error("Probed node types mismatch: '%s' != '%s'!", get_class($this), get_class($other)); return; } if ($this->value !== $other->value) { $result->error("Terminal value mismatch: '%s' != '%s'!", $this->value, $other->value); } }
private function assertNotificationOk(Notification $n) { $this->assertTrue($n->isOk(), $n->report()); }
/** * Probes equivalence of itself against an other node and collects all * errors in the passed {@link Notification} object. * * @param Node $other Node to compare against. * @param Notification $result Object which collects all equivlanece violations. * * @return void */ public function probeEquivalence(Node $other, Notification $result) { if (!$other instanceof Composite) { $result->error("Probed node is not a composite node: '%s' vs. '%s'!", get_class($this), get_class($other)); return; } if (get_class($this) !== get_class($other)) { $result->error("Probed node types mismatch: '%s' != '%s'!", get_class($this), get_class($other)); return; } /* @var $other Composite */ if ($this->countChildren() !== $other->countChildren()) { $result->error("Node %s has different child count than other: %d != %d!", $this->getNodeName(), $this->countChildren(), $other->countChildren()); } $subnodes = $this->getIterator(); $otherSubnodes = $other->getIterator(); foreach ($subnodes as $subnode) { if ($otherSubnodes->offsetExists($subnodes->key())) { $subnode->probeEquivalence($otherSubnodes->offsetGet($subnodes->key()), $result); } else { $result->error("Other node has not the expected subnode!"); } } }