public function PhpArgumentValidatorTest::testArgumentValidatePhp in PHP 8
Tests the validateArgument question.
File
- src/
Tests/ Plugin/ views/ PhpArgumentValidatorTest.php, line 45
Class
- PhpArgumentValidatorTest
- Tests Views PHP argument validators.
Namespace
Drupal\php\Tests\Plugin\viewsCode
public function testArgumentValidatePhp() {
$string = $this
->randomMachineName();
$view = Views::getView('test_view_argument_validate_php');
$view
->setDisplay();
$view->displayHandlers
->get('default')->options['arguments']['null']['validate_options']['code'] = 'return $argument == \'' . $string . '\';';
$view
->initHandlers();
$this
->assertTrue($view->argument['null']
->validateArgument($string));
// Reset saved argument validation.
$view->argument['null']->argument_validated = NULL;
$this
->assertFalse($view->argument['null']
->validateArgument($this
->randomMachineName()));
}