diff --git a/composer.json b/composer.json index 8a1b7d0..3a49ca7 100644 --- a/composer.json +++ b/composer.json @@ -1,15 +1,18 @@ { - "name": "drupal/twig_tweak", - "type": "drupal-module", - "description": "A Twig extension with some useful functions and filters for Drupal development.", - "keywords": ["Drupal", "Twig"], - "license": "GPL-2.0+", - "homepage": "https://www.drupal.org/project/twig_tweak", - "suggest": { - "symfony/var-dumper": "better dump() function for debugging Twig variables" - }, - "support": { - "issues": "https://www.drupal.org/project/issues/twig_tweak", - "source": "http://cgit.drupalcode.org/twig_tweak" - } + "name": "drupal/twig_tweak", + "type": "drupal-module", + "description": "A Twig extension with some useful functions and filters for Drupal development.", + "keywords": ["Drupal", "Twig"], + "license": "GPL-2.0+", + "homepage": "https://www.drupal.org/project/twig_tweak", + "suggest": { + "symfony/var-dumper": "better dump() function for debugging Twig variables" + }, + "support": { + "issues": "https://www.drupal.org/project/issues/twig_tweak", + "source": "http://cgit.drupalcode.org/twig_tweak" + }, + "require": { + "drupal/core": "^8.5" + } } diff --git a/src/TwigExtension.php b/src/TwigExtension.php index 676310f..71bbaa8 100644 --- a/src/TwigExtension.php +++ b/src/TwigExtension.php @@ -312,11 +312,9 @@ class TwigExtension extends \Twig_Extension { * * @return array * A render array to disable caching. - * - * @see drupal_set_message() */ 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; return $build; } diff --git a/tests/src/Functional/TwigTweakTest.php b/tests/src/Functional/TwigTweakTest.php index 3108f5c..0b6279a 100644 --- a/tests/src/Functional/TwigTweakTest.php +++ b/tests/src/Functional/TwigTweakTest.php @@ -12,6 +12,11 @@ use Drupal\Tests\BrowserTestBase; */ class TwigTweakTest extends BrowserTestBase { + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'classy'; + /** * {@inheritdoc} */ @@ -73,7 +78,6 @@ class TwigTweakTest extends BrowserTestBase { // Test region. $xpath = '//div[@class = "tt-region"]'; $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"]'; $this->assertByXpath($xpath);