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()
- 10 core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php \Drupal\Tests\node\Functional\Views\FilterNodeAccessTest::setUp()
- 11.x 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 42
Class
- FilterNodeAccessTest
- Tests the node_access filter handler.
Namespace
Drupal\Tests\node\Functional\ViewsCode
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$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' => t('@private_public Article created by @user', [
'@private_public' => $type,
'@user' => $web_user->getAccountName(),
]),
'type' => 'article',
'uid' => $web_user->id(),
'private' => (bool) $is_private,
];
$node = $this->drupalCreateNode($settings);
$this->assertEqual($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.