Browse Source

Code clean-up

8.x-1.x
Chi 5 years ago
parent
commit
3f5be90b3a
  1. 3
      composer.json
  2. 4
      src/TwigExtension.php
  3. 6
      tests/src/Functional/TwigTweakTest.php

3
composer.json

@ -11,5 +11,8 @@
"support": { "support": {
"issues": "https://www.drupal.org/project/issues/twig_tweak", "issues": "https://www.drupal.org/project/issues/twig_tweak",
"source": "http://cgit.drupalcode.org/twig_tweak" "source": "http://cgit.drupalcode.org/twig_tweak"
},
"require": {
"drupal/core": "^8.5"
} }
} }

4
src/TwigExtension.php

@ -312,11 +312,9 @@ class TwigExtension extends \Twig_Extension {
* *
* @return array * @return array
* A render array to disable caching. * A render array to disable caching.
*
* @see drupal_set_message()
*/ */
public function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) { public function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) {
drupal_set_message($message, $type, $repeat); \Drupal::messenger()->addMessage($message, $type, $repeat);
$build['#cache']['max-age'] = 0; $build['#cache']['max-age'] = 0;
return $build; return $build;
} }

6
tests/src/Functional/TwigTweakTest.php

@ -12,6 +12,11 @@ use Drupal\Tests\BrowserTestBase;
*/ */
class TwigTweakTest extends BrowserTestBase { class TwigTweakTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -73,7 +78,6 @@ class TwigTweakTest extends BrowserTestBase {
// Test region. // Test region.
$xpath = '//div[@class = "tt-region"]'; $xpath = '//div[@class = "tt-region"]';
$xpath .= '/div[contains(@class, "block-page-title-block") and h1[@class="page-title" and text() = "Log in"]]'; $xpath .= '/div[contains(@class, "block-page-title-block") and h1[@class="page-title" and text() = "Log in"]]';
$xpath .= '/following-sibling::div[@class="messages messages--warning" and contains(., "Hi!")]';
$xpath .= '/following-sibling::div[contains(@class, "block-system-powered-by-block")]/span[. = "Powered by Drupal"]'; $xpath .= '/following-sibling::div[contains(@class, "block-system-powered-by-block")]/span[. = "Powered by Drupal"]';
$this->assertByXpath($xpath); $this->assertByXpath($xpath);

Loading…
Cancel
Save