/** * @Then /^final source of template "([^"]*)" should be:$/ */ public function finalSourceOfTemplateShouldBe($template, PyStringNode $expected) { if (null !== $this->override) { $this->registry->add($this->override); } $actual = preg_replace("/\r|\n/", "", $this->twig->getLoader()->getSource($template)); $expected = preg_replace("/\r|\n/", "", $expected->getRaw()); $actual = preg_replace('~>\\s+<~m', '><', $actual); $expected = preg_replace('~>\\s+<~m', '><', $expected); if ($expected !== $actual) { $actual = explode(PHP_EOL, (string) $actual); $expected = explode(PHP_EOL, (string) $expected); $diff = new \Diff($expected, $actual, array()); $renderer = new \Diff_Renderer_Text_Unified(); $text = $diff->render($renderer); throw new \Exception(sprintf("Output does not match expected template. \n\n %s", $text)); } }