function EntityTest::testValidateArgumentAccess

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::testValidateArgumentAccess()
  2. 10 core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::testValidateArgumentAccess()
  3. 11.x core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::testValidateArgumentAccess()

Tests the validate argument method with access and no bundles.

See also

\Drupal\views\Plugin\views\argument_validator\Entity::validateArgument()

File

core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php, line 143

Class

EntityTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21views%21argument_validator%21Entity.php/class/Entity/8.9.x" title="Defines a argument validator plugin for each entity type." class="local">\Drupal\views\Plugin\views\argument_validator\Entity</a> @group views

Namespace

Drupal\Tests\views\Unit\Plugin\argument_validator

Code

public function testValidateArgumentAccess() {
    $options = [];
    $options['access'] = TRUE;
    $options['bundles'] = [];
    $options['operation'] = 'test_op';
    $this->argumentValidator
        ->init($this->executable, $this->display, $options);
    $this->assertFalse($this->argumentValidator
        ->validateArgument(3));
    $this->assertFalse($this->argumentValidator
        ->validateArgument(''));
    $this->assertTrue($this->argumentValidator
        ->validateArgument(1));
    $options = [];
    $options['access'] = TRUE;
    $options['bundles'] = [];
    $options['operation'] = 'test_op_2';
    $this->argumentValidator
        ->init($this->executable, $this->display, $options);
    $this->assertFalse($this->argumentValidator
        ->validateArgument(3));
    $this->assertFalse($this->argumentValidator
        ->validateArgument(''));
    $this->assertFalse($this->argumentValidator
        ->validateArgument(1));
    $this->assertFalse($this->argumentValidator
        ->validateArgument(2));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.