protected function CommentDefaultFormatterCacheTagsTest::setUp in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php \Drupal\comment\Tests\CommentDefaultFormatterCacheTagsTest::setUp()
Performs setup tasks before each individual test method is run.
Overrides EntityUnitTestBase::setUp
File
- core/
modules/ comment/ src/ Tests/ CommentDefaultFormatterCacheTagsTest.php, line 37 - Contains \Drupal\comment\Tests\CommentDefaultFormatterCacheTagsTest.
Class
- CommentDefaultFormatterCacheTagsTest
- Tests the bubbling up of comment cache tags when using the Comment list formatter on an entity.
Namespace
Drupal\comment\TestsCode
protected function setUp() {
parent::setUp();
$session = new Session();
$request = Request::create('/');
$request
->setSession($session);
/** @var RequestStack $stack */
$stack = $this->container
->get('request_stack');
$stack
->pop();
$stack
->push($request);
// Set the current user to one that can access comments. Specifically, this
// user does not have access to the 'administer comments' permission, to
// ensure only published comments are visible to the end user.
$current_user = $this->container
->get('current_user');
$current_user
->setAccount($this
->createUser(array(), array(
'access comments',
)));
// Install tables and config needed to render comments.
$this
->installSchema('comment', array(
'comment_entity_statistics',
));
$this
->installConfig(array(
'system',
'filter',
'comment',
));
// Comment rendering generates links, so build the router.
$this
->installSchema('system', array(
'router',
));
$this->container
->get('router.builder')
->rebuild();
// Set up a field, so that the entity that'll be referenced bubbles up a
// cache tag when rendering it entirely.
$this
->addDefaultCommentField('entity_test', 'entity_test');
}