diff --git a/.travis.yml b/.travis.yml index 5edf3829a..23f13e6ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ env: # For functional tests - COMPOSE_FILE="doc/docker/base-dev.yml:doc/docker/selenium.yml" - SYMFONY_ENV=behat + - SYMFONY_DEBUG=1 matrix: # mark as finished before allow_failures are run diff --git a/features/Context/PagelayoutContext.php b/features/Context/PagelayoutContext.php index 6f37bfccd..84d1e5cb6 100644 --- a/features/Context/PagelayoutContext.php +++ b/features/Context/PagelayoutContext.php @@ -12,6 +12,9 @@ class PagelayoutContext extends RawMinkContext implements Context, SnippetAcceptingContext { + /** @var string Regex matching the way the Twig template name is inserted in debug mode */ + const TWIG_DEBUG_STOP_REGEX = ''; + /** * @var ConfigResolverInterface */ @@ -30,7 +33,7 @@ public function __construct(ConfigResolverInterface $configResolver) */ public function aPagelayoutIsConfigured() { - $this->configResolver->hasParameter('pagelayout'); + Assertion::assertTrue($this->configResolver->hasParameter('pagelayout')); } /** @@ -38,9 +41,8 @@ public function aPagelayoutIsConfigured() */ public function itIsRenderedUsingTheConfiguredPagelayout() { - Assertion::assertContains( - sprintf('', $this->configResolver->getParameter('pagelayout')), - $this->getSession()->getPage()->getOuterHtml() - ); + $pageLayout = $this->configResolver->getParameter('pagelayout'); + $searchedPattern = sprintf(self::TWIG_DEBUG_STOP_REGEX, preg_quote($pageLayout, null)); + Assertion::assertRegExp($searchedPattern, $this->getSession()->getPage()->getOuterHtml()); } } diff --git a/features/Context/UserRegistrationContext.php b/features/Context/UserRegistrationContext.php index 33bd89962..644b0980c 100644 --- a/features/Context/UserRegistrationContext.php +++ b/features/Context/UserRegistrationContext.php @@ -27,6 +27,9 @@ class UserRegistrationContext extends RawMinkContext implements Context, Snippet { use RepositoryContext; + /** @var string Regex matching the way the Twig template name is inserted in debug mode */ + const TWIG_DEBUG_STOP_REGEX = ''; + private static $password = 'publish'; private static $language = 'eng-GB'; @@ -336,7 +339,8 @@ public function createTemplateAt($path, PyStringNode $contents) public function thePageIsRenderedUsingTheTemplateConfiguredIn($template) { $html = $this->getSession()->getPage()->getOuterHtml(); - $found = (strpos($html, sprintf('', $template)) !== false); + $searchedPattern = sprintf(self::TWIG_DEBUG_STOP_REGEX, preg_quote($template, null)); + $found = preg_match($searchedPattern, $html) === 1; if (!$found && strpos($template, ':') === false) { $alternativeTemplate = sprintf( @@ -344,7 +348,8 @@ public function thePageIsRenderedUsingTheTemplateConfiguredIn($template) dirname($template), basename($template) ); - $found = (strpos($html, sprintf('', $alternativeTemplate)) !== false); + $searchedPattern = sprintf(self::TWIG_DEBUG_STOP_REGEX, preg_quote($alternativeTemplate, null)); + $found = preg_match($searchedPattern, $html) === 1; } Assertion::assertTrue( diff --git a/features/User/Registration/user_registration.feature b/features/User/Registration/user_registration.feature index 200884b11..3efaebae0 100644 --- a/features/User/Registration/user_registration.feature +++ b/features/User/Registration/user_registration.feature @@ -42,10 +42,10 @@ Scenario: The user registration templates can be customized default: user_registration: templates: - form: 'user/registration_form.html.twig' - confirmation: 'user/registration_confirmation.html.twig' + form: 'AppBundle:user:registration_form.html.twig' + confirmation: 'AppBundle:user:registration_confirmation.html.twig' """ - And the following template in "app/Resources/views/user/registration_form.html.twig": + And the following template in "src/AppBundle/Resources/views/user/registration_form.html.twig": """ {% extends noLayout is defined and noLayout == true ? viewbaseLayout : pagelayout %} @@ -57,7 +57,7 @@ Scenario: The user registration templates can be customized {% endblock %} """ - And the following template in "app/Resources/views/user/registration_confirmation.html.twig": + And the following template in "src/AppBundle/Resources/views/user/registration_confirmation.html.twig": """ {% extends noLayout is defined and noLayout == true ? viewbaseLayout : pagelayout %}