function DisplayPageWebTest::testArguments

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::testArguments()
  2. 10 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 as webtest.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testArguments() {
  $this->drupalGet('test_route_without_arguments');
  $this->assertSession()
    ->statusCodeEquals(200);
  $result = $this->xpath('//span[@class="field-content"]');
  $this->assertCount(5, $result, 'All entries was returned');
  $this->drupalGet('test_route_without_arguments/1');
  $this->assertSession()
    ->statusCodeEquals(404);
  $this->drupalGet('test_route_with_argument/1');
  $this->assertSession()
    ->statusCodeEquals(200);
  $this->assertCacheContexts([
    'languages:language_interface',
    'route',
    'theme',
    'url',
  ]);
  $result = $this->xpath('//span[@class="field-content"]');
  $this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.');
  $this->assertEqual($result[0]->getText(), 1, 'The passed ID was returned.');
  $this->drupalGet('test_route_with_suffix/1/suffix');
  $this->assertSession()
    ->statusCodeEquals(200);
  $result = $this->xpath('//span[@class="field-content"]');
  $this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.');
  $this->assertEqual($result[0]->getText(), 1, 'The passed ID was returned.');
  $this->drupalGet('test_route_with_suffix_and_argument/1/suffix/2');
  $this->assertSession()
    ->statusCodeEquals(200);
  $result = $this->xpath('//span[@class="field-content"]');
  $this->assertCount(0, $result, 'No result was returned.');
  $this->drupalGet('test_route_with_suffix_and_argument/1/suffix/1');
  $this->assertSession()
    ->statusCodeEquals(200);
  $result = $this->xpath('//span[@class="field-content"]');
  $this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.');
  $this->assertEqual($result[0]->getText(), 1, 'The passed ID was returned.');
  $this->drupalGet('test_route_with_long_argument/1');
  $this->assertSession()
    ->statusCodeEquals(200);
  $result = $this->xpath('//span[@class="field-content"]');
  $this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.');
  $this->assertEqual($result[0]->getText(), 1, 'The passed ID was returned.');
}

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