function TwigExtensionTest::testDump
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php \Drupal\Tests\system\Functional\Theme\TwigExtensionTest::testDump()
- 11.x core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php \Drupal\Tests\system\Functional\Theme\TwigExtensionTest::testDump()
Tests the dump function.
File
-
core/
modules/ system/ tests/ src/ Functional/ Theme/ TwigExtensionTest.php, line 101
Class
- TwigExtensionTest
- Tests Twig extensions.
Namespace
Drupal\Tests\system\Functional\ThemeCode
public function testDump() : void {
// Test Twig Debug disabled.
$this->drupalGet('/twig-theme-test/dump');
$this->assertSession()
->elementsCount('css', '.sf-dump', 0);
// Test Twig Debug enabled.
$parameters = $this->container
->getParameter('twig.config');
$parameters['debug'] = TRUE;
$this->setContainerParameter('twig.config', $parameters);
$this->resetAll();
$this->drupalGet('/twig-theme-test/dump');
$dumps = $this->getSession()
->getPage()
->findAll('css', '.sf-dump');
$this->assertEquals(4, count($dumps));
// Test dumping single variable.
$this->assertStringContainsString('💩', $dumps[0]->getText());
$this->assertStringNotContainsString('🐣', $dumps[0]->getText());
// Test dumping context.
$this->assertStringContainsString('"bar" => "🐣"', $dumps[1]->getText());
// Test dump as a variadic.
$this->assertStringContainsString('💩', $dumps[2]->getText());
$this->assertStringContainsString('☄️', $dumps[3]->getText());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.