You are here

public function ArgumentValidatorTest::testSpecifyValidation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views_ui/src/Tests/ArgumentValidatorTest.php \Drupal\views_ui\Tests\ArgumentValidatorTest::testSpecifyValidation()

Tests the 'Specify validation criteria' checkbox functionality.

File

core/modules/views_ui/src/Tests/ArgumentValidatorTest.php, line 29
Contains \Drupal\views_ui\Tests\ArgumentValidatorTest.

Class

ArgumentValidatorTest
Tests the Argument validator through the UI.

Namespace

Drupal\views_ui\Tests

Code

public function testSpecifyValidation() {

  // Specify a validation based on Node for the 'id' argument on the default
  // display and assert that this works.
  $this
    ->saveArgumentHandlerWithValidationOptions(TRUE);
  $view = Views::getView('test_argument');
  $handler = $view
    ->getHandler('default', 'argument', 'id');
  $this
    ->assertTrue($handler['specify_validation'], 'Validation for this argument has been turned on.');
  $this
    ->assertEqual('entity:node', $handler['validate']['type'], 'Validation for the argument is based on the node.');

  // Uncheck the 'Specify validation criteria' checkbox and expect the
  // validation type to be reset back to 'none'.
  $this
    ->saveArgumentHandlerWithValidationOptions(FALSE);
  $view = Views::getView('test_argument');
  $handler = $view
    ->getHandler('default', 'argument', 'id');
  $this
    ->assertFalse($handler['specify_validation'], 'Validation for this argument has been turned off.');
  $this
    ->assertEqual('none', $handler['validate']['type'], 'Validation for the argument has been reverted to Basic Validation.');
}