You are here

class ArgumentValidatorTest in Drupal 10

Same name in this branch
  1. 10 core/modules/views_ui/tests/src/Functional/ArgumentValidatorTest.php \Drupal\Tests\views_ui\Functional\ArgumentValidatorTest
  2. 10 core/modules/views/tests/src/Kernel/Plugin/ArgumentValidatorTest.php \Drupal\Tests\views\Kernel\Plugin\ArgumentValidatorTest
  3. 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_validator/ArgumentValidatorTest.php \Drupal\views_test_data\Plugin\views\argument_validator\ArgumentValidatorTest
Same name and namespace in other branches
  1. 8 core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_validator/ArgumentValidatorTest.php \Drupal\views_test_data\Plugin\views\argument_validator\ArgumentValidatorTest
  2. 9 core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_validator/ArgumentValidatorTest.php \Drupal\views_test_data\Plugin\views\argument_validator\ArgumentValidatorTest

Defines an argument validator test plugin.

Plugin annotation


@ViewsArgumentValidator(
  id = "argument_validator_test",
  title = @Translation("Argument validator test")
)

Hierarchy

  • class \Drupal\views_test_data\Plugin\views\argument_validator\ArgumentValidatorTest extends \Drupal\views\Plugin\views\argument_validator\ArgumentValidatorPluginBase

Expanded class hierarchy of ArgumentValidatorTest

1 file declares its use of ArgumentValidatorTest
ArgumentValidatorTest.php in core/modules/views/tests/src/Kernel/Plugin/ArgumentValidatorTest.php
3 string references to 'ArgumentValidatorTest'
ArgumentValidatorTest::calculateDependencies in core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_validator/ArgumentValidatorTest.php
ViewEntityDependenciesTest::testGetDependencies in core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php
Tests the getDependencies method.
views.view.test_argument_dependency.yml in core/modules/views/tests/modules/views_test_config/test_views/views.view.test_argument_dependency.yml
core/modules/views/tests/modules/views_test_config/test_views/views.view.test_argument_dependency.yml

File

core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_validator/ArgumentValidatorTest.php, line 15

Namespace

Drupal\views_test_data\Plugin\views\argument_validator
View source
class ArgumentValidatorTest extends ArgumentValidatorPluginBase {

  /**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    return [
      'content' => [
        'ArgumentValidatorTest',
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['test_value'] = [
      'default' => '',
    ];
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function validateArgument($arg) {
    if ($arg === 'this value should be replaced') {

      // Set the argument to a numeric value so this is valid on PostgreSQL for
      // numeric fields.
      $this->argument->argument = '1';
      return TRUE;
    }
    return $arg == $this->options['test_value'];
  }

}

Members