class RenderWebTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Functional/Common/RenderWebTest.php \Drupal\Tests\system\Functional\Common\RenderWebTest
- 10 core/modules/system/tests/src/Functional/Common/RenderWebTest.php \Drupal\Tests\system\Functional\Common\RenderWebTest
- 8.9.x core/modules/system/tests/src/Functional/Common/RenderWebTest.php \Drupal\Tests\system\Functional\Common\RenderWebTest
Performs integration tests on \Drupal::service('renderer')->render().
@group Common
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\Common\RenderWebTest uses \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of RenderWebTest
File
-
core/
modules/ system/ tests/ src/ Functional/ Common/ RenderWebTest.php, line 15
Namespace
Drupal\Tests\system\Functional\CommonView source
class RenderWebTest extends BrowserTestBase {
use AssertPageCacheContextsAndTagsTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'common_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Asserts the cache context for the wrapper format is always present.
*/
public function testWrapperFormatCacheContext() {
$this->drupalGet('common-test/type-link-active-class');
$this->assertStringStartsWith("<!DOCTYPE html>\n<html", $this->getSession()
->getPage()
->getContent());
$this->assertSession()
->responseHeaderEquals('Content-Type', 'text/html; charset=UTF-8');
$this->assertSession()
->titleEquals('Test active link class | Drupal');
$this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
$this->drupalGet('common-test/type-link-active-class', [
'query' => [
MainContentViewSubscriber::WRAPPER_FORMAT => 'json',
],
]);
$this->assertSession()
->responseHeaderEquals('Content-Type', 'application/json');
$json = Json::decode($this->getSession()
->getPage()
->getContent());
$this->assertEquals([
'content',
'title',
], array_keys($json));
$this->assertSame('Test active link class', $json['title']);
$this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.