public function ArgumentDefaultTest::testArgumentDefaultFixed in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php \Drupal\Tests\views\Functional\Plugin\ArgumentDefaultTest::testArgumentDefaultFixed()
- 9 core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php \Drupal\Tests\views\Functional\Plugin\ArgumentDefaultTest::testArgumentDefaultFixed()
Tests fixed default argument.
File
- core/
modules/ views/ tests/ src/ Functional/ Plugin/ ArgumentDefaultTest.php, line 114
Class
- ArgumentDefaultTest
- Tests pluggable argument_default for views.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testArgumentDefaultFixed() {
$random = $this
->randomMachineName();
$view = Views::getView('test_argument_default_fixed');
$view
->setDisplay();
$options = $view->display_handler
->getOption('arguments');
$options['null']['default_argument_options']['argument'] = $random;
$view->display_handler
->overrideOption('arguments', $options);
$view
->initHandlers();
$this
->assertEquals($random, $view->argument['null']
->getDefaultArgument(), 'Fixed argument should be used by default.');
// Make sure that a normal argument provided is used
$random_string = $this
->randomMachineName();
$view
->executeDisplay('default', [
$random_string,
]);
$this
->assertEquals($random_string, $view->args[0], 'Provided argument should be used.');
}