function FilterNodeAccessTest::setUp
Same name in other branches
- 9 core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php \Drupal\Tests\node\Functional\Views\FilterNodeAccessTest::setUp()
- 8.9.x core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php \Drupal\Tests\node\Functional\Views\FilterNodeAccessTest::setUp()
- 10 core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php \Drupal\Tests\node\Functional\Views\FilterNodeAccessTest::setUp()
Overrides NodeTestBase::setUp
File
-
core/
modules/ node/ tests/ src/ Functional/ Views/ FilterNodeAccessTest.php, line 44
Class
- FilterNodeAccessTest
- Tests the node_access filter handler.
Namespace
Drupal\Tests\node\Functional\ViewsCode
protected function setUp($import_test_views = TRUE, $modules = [
'node_test_views',
]) : void {
parent::setUp($import_test_views, $modules);
$this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
node_access_test_add_field(NodeType::load('article'));
node_access_rebuild();
\Drupal::state()->set('node_access_test.private', TRUE);
$num_simple_users = 2;
$this->users = [];
for ($i = 0; $i < $num_simple_users; $i++) {
$this->users[$i] = $this->drupalCreateUser([
'access content',
'create article content',
]);
}
foreach ($this->users as $web_user) {
$this->drupalLogin($web_user);
foreach ([
0 => 'Public',
1 => 'Private',
] as $is_private => $type) {
$settings = [
'body' => [
[
'value' => $type . ' node',
'format' => filter_default_format(),
],
],
'title' => "{$type} Article created by " . $web_user->getAccountName(),
'type' => 'article',
'uid' => $web_user->id(),
'private' => (bool) $is_private,
];
$node = $this->drupalCreateNode($settings);
$this->assertEquals($is_private, (int) $node->private->value, 'The private status of the node was properly set in the node_access_test table.');
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.