$view = Views::
getView('test_field_argument_tokens'
);
$this->
executeView($view,
['{{ { "#pre_render": ["\Drupal\views_test_data\Controller\ViewsTestDataController::preRender"]} }}'
]);
$name_field_0 =
$view->field
['name'
];
// Test the old style tokens.
$name_field_0->options
['alter'
]['alter_text'
] = TRUE;
$name_field_0->options
['alter'
]['text'
] = '%1 !1';
$row =
$view->result
[0
];
$output =
$renderer->
executeInRenderContext(new RenderContext(),
function D
) use ($name_field_0,
$row) { return $name_field_0->
advancedRender($row);
});
$this->
assertStringNotContainsString('\Drupal\views_test_data\Controller\ViewsTestDataController::preRender executed',
(string) $output, 'Ensure that the pre_render function was not executed'
);
$this->
assertEquals('%1 !1',
(string) $output, "Ensure that old style placeholders aren't replaced"
);
// This time use new style tokens but ensure that we still don't allow
// arbitrary code execution.
$name_field_0->options
['alter'
]['alter_text'
] = TRUE;
$name_field_0->options
['alter'
]['text'
] = '{{ arguments.null }} {{ raw_arguments.null }}';
$row =
$view->result
[0
];