function DisplayPageWebTest::testArguments

Same name in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::testArguments()
  2. 8.9.x core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::testArguments()
  3. 11.x core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::testArguments()

Tests arguments.

File

core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php, line 50

Class

DisplayPageWebTest
Tests the views page display plugin.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testArguments() : void {
    $xpath = '//span[@class="field-content"]';
    // Ensure that all the entries are returned.
    $this->drupalGet('test_route_without_arguments');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->elementsCount('xpath', $xpath, 5);
    $this->drupalGet('test_route_without_arguments/1');
    $this->assertSession()
        ->statusCodeEquals(404);
    // Ensure that just the filtered entry is returned.
    $this->drupalGet('test_route_with_argument/1');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertCacheContexts([
        'languages:language_interface',
        'route',
        'theme',
        'url',
    ]);
    $this->assertSession()
        ->elementsCount('xpath', $xpath, 1);
    $this->assertSession()
        ->elementTextEquals('xpath', $xpath, '1');
    // Ensure that just the filtered entry is returned.
    $this->drupalGet('test_route_with_suffix/1/suffix');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->elementsCount('xpath', $xpath, 1);
    $this->assertSession()
        ->elementTextEquals('xpath', $xpath, '1');
    // Ensure that no result is returned.
    $this->drupalGet('test_route_with_suffix_and_argument/1/suffix/2');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->elementNotExists('xpath', $xpath);
    // Ensure that just the filtered entry is returned.
    $this->drupalGet('test_route_with_suffix_and_argument/1/suffix/1');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->elementsCount('xpath', $xpath, 1);
    $this->assertSession()
        ->elementTextEquals('xpath', $xpath, '1');
    // Ensure that just the filtered entry is returned.
    $this->drupalGet('test_route_with_long_argument/1');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->elementsCount('xpath', $xpath, 1);
    $this->assertSession()
        ->elementTextEquals('xpath', $xpath, '1');
}

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