Commit 6ba3cb12 authored by webchick's avatar webchick

Issue #1937212 by ACF: Change node test variables...

Issue #1937212 by ACF: Change node test variables 'node_test_change_view_mode()' and 'node_access_test_secret_catalan()' to the state system.
parent 26c13e79
......@@ -80,7 +80,7 @@ function testNodeAccess() {
// Reset the node access cache and turn on our test node_access() code.
drupal_static_reset('node_access');
variable_set('node_access_test_secret_catalan', 1);
state()->set('node_access_test_secret_catalan', 1);
// Tests that Hungarian is still accessible.
$this->assertNodeAccess($expected_node_access, $node, $web_user, 'hu');
......
......@@ -43,7 +43,7 @@ function testNodeViewModeChange() {
$node = $this->drupalGetNodeByTitle($edit["title"]);
// Set the flag to alter the view mode and view the node.
variable_set('node_test_change_view_mode', 'teaser');
state()->set('node_test_change_view_mode', 'teaser');
$this->drupalGet('node/' . $node->nid);
// Check that teaser mode is viewed.
......
......@@ -241,7 +241,8 @@ function _node_access_test_node_write(Node $node) {
* Implements hook_node_access().
*/
function node_access_test_node_access($node, $op, $account, $langcode) {
if (variable_get('node_access_test_secret_catalan', 0) && $langcode == 'ca') {
$secret_catalan = state()->get('node_access_test_secret_catalan') ?: 0;
if ($secret_catalan && $langcode == 'ca') {
// Make all Catalan content secret.
return NODE_ACCESS_DENY;
}
......
......@@ -160,7 +160,8 @@ function node_test_node_update(Node $node) {
*/
function node_test_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
// Only alter the view mode if we are on the test callback.
if ($change_view_mode = variable_get('node_test_change_view_mode', '')) {
$change_view_mode = state()->get( 'node_test_change_view_mode') ?: '';
if ($change_view_mode) {
$view_mode = $change_view_mode;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment