Skip to content

Commit

Permalink
Merge branch '1.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Nocon committed Apr 12, 2018
2 parents fa91b3f + a8290b1 commit ee997b1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions features/Context/PagelayoutContext.php
Expand Up @@ -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 = '<!-- STOP .*%s.* -->';

/**
* @var ConfigResolverInterface
*/
Expand All @@ -30,17 +33,16 @@ public function __construct(ConfigResolverInterface $configResolver)
*/
public function aPagelayoutIsConfigured()
{
$this->configResolver->hasParameter('pagelayout');
Assertion::assertTrue($this->configResolver->hasParameter('pagelayout'));
}

/**
* @Then /^it is rendered using the configured pagelayout$/
*/
public function itIsRenderedUsingTheConfiguredPagelayout()
{
Assertion::assertContains(
sprintf('<!-- STOP %s -->', $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());
}
}
9 changes: 7 additions & 2 deletions features/Context/UserRegistrationContext.php
Expand Up @@ -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 = '<!-- STOP .*%s.* -->';

private static $password = 'publish';

private static $language = 'eng-GB';
Expand Down Expand Up @@ -336,15 +339,17 @@ public function createTemplateAt($path, PyStringNode $contents)
public function thePageIsRenderedUsingTheTemplateConfiguredIn($template)
{
$html = $this->getSession()->getPage()->getOuterHtml();
$found = (strpos($html, sprintf('<!-- STOP %s -->', $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(
':%s:%s',
dirname($template),
basename($template)
);
$found = (strpos($html, sprintf('<!-- STOP %s -->', $alternativeTemplate)) !== false);
$searchedPattern = sprintf(self::TWIG_DEBUG_STOP_REGEX, preg_quote($alternativeTemplate, null));
$found = preg_match($searchedPattern, $html) === 1;
}

Assertion::assertTrue(
Expand Down
8 changes: 4 additions & 4 deletions features/User/Registration/user_registration.feature
Expand Up @@ -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 %}
Expand All @@ -57,7 +57,7 @@ Scenario: The user registration templates can be customized
</section>
{% 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 %}
Expand Down

0 comments on commit ee997b1

Please sign in to comment.