public function testNodeAccessRecords() { // Create an article node.
$node1 =
$this->
drupalCreateNode(['type' => 'article'
]);
$this->
assertNotEmpty(Node::
load($node1->
id()), 'Article node created.'
);
// Check to see if grants added by node_test_node_access_records made it in.
$connection = Database::
getConnection();
$records =
$connection->
select('node_access', 'na'
) ->
fields('na',
['realm', 'gid'
]) ->
condition('nid',
$node1->
id()) ->
execute() ->
fetchAll();
$this->
assertCount(1,
$records, 'Returned the correct number of rows.'
);
$this->
assertEquals('test_article_realm',
$records[0
]->realm, 'Grant with article_realm acquired for node without alteration.'
);
$this->
assertEquals(1,
$records[0
]->gid, 'Grant with gid = 1 acquired for node without alteration.'
);
// Create an unpromoted "Basic page" node.
$node2 =
$this->
drupalCreateNode(['type' => 'page', 'promote' => 0
]);
$this->
assertNotEmpty(Node::
load($node2->
id()), 'Unpromoted basic page node created.'
);
// Check to see if grants added by node_test_node_access_records made it in.
$records =
$connection->
select('node_access', 'na'
) ->
fields('na',
['realm', 'gid'
])