/** * Compare two stack template models. * * @param Template $templateA First template model to compare. * @param Template $templateB Second template model to compare. * @return string Rendered unified diff of the changes between the first * and second template models. */ public function compareTemplate(Template $templateA, Template $templateB) { // The difference engine expects an array of strings, so get the // template bodies as JSON and explode in to separate lines. $diff = new Diff(explode("\n", $templateA->getBodyJSON()), explode("\n", $templateB->getBodyJSON()), []); return $diff->render(new Diff_Renderer_Text_Unified()); }
public function testFailedGetBodyJSON() { // Construct a body that is impossible to encode as JSON. $body = new stdClass(); $body->body = $body; $this->setExpectedException('UnexpectedValueException'); $template = new Template('foo', $body); $template->getBodyJSON(); }
public function isIdentical(self $template) { return $this->getName() === $template->getName() && $this->getBodyJSON() === $template->getBodyJSON(); }