You are here

function ArgumentValidatorTest::testArgumentValidatePhp in Views (for Drupal 7) 8.3

File

lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php, line 23
Definition of Drupal\views\Tests\Plugin\ArgumentValidatorTest.

Class

ArgumentValidatorTest
Tests Views argument validators.

Namespace

Drupal\views\Tests\Plugin

Code

function testArgumentValidatePhp() {
  $string = $this
    ->randomName();
  $view = $this
    ->createViewFromConfig('test_view_argument_validate_php');
  $view->displayHandlers['default']->options['arguments']['null']['validate_options']['code'] = 'return $argument == \'' . $string . '\';';
  $view
    ->preExecute();
  $view
    ->initHandlers();
  $this
    ->assertTrue($view->argument['null']
    ->validateArgument($string));

  // Reset safed argument validation.
  $view->argument['null']->argument_validated = NULL;
  $this
    ->assertFalse($view->argument['null']
    ->validateArgument($this
    ->randomName()));
}