$web_user =
$this->
drupalCreateUser(['access content'
]);
$expected_node_access =
['view' => TRUE, 'update' => FALSE, 'delete' => FALSE
];
$expected_node_access_no_access =
['view' => FALSE, 'update' => FALSE, 'delete' => FALSE
];
// Creating a public node with langcode Hungarian, will be saved as the
// fallback in node access table.
$node_public_hu =
$this->
drupalCreateNode(['body' =>
[[]], 'langcode' => 'hu', 'private' => FALSE
]);
$this->
assertSame('hu',
$node_public_hu->
language()->
getId(), 'Node created as Hungarian.'
);
// Tests the default access is provided for the public Hungarian node.
$this->
assertNodeAccess($expected_node_access,
$node_public_hu,
$web_user);
// Tests that Hungarian provided specifically results in the same.
$this->
assertNodeAccess($expected_node_access,
$node_public_hu->
getTranslation('hu'
),
$web_user);
// Creating a public node with no special langcode, like when no language
// module enabled.
$node_public_no_language =
$this->
drupalCreateNode([ 'private' => FALSE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
]);
$this->
assertSame(LanguageInterface::LANGCODE_NOT_SPECIFIED,
$node_public_no_language->
language()->
getId(), 'Node created with not specified language.'
);