You are here

public function DisplayPageWebTest::testArguments in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php \Drupal\views\Tests\Plugin\DisplayPageWebTest::testArguments()

Tests arguments.

File

core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php, line 49
Contains \Drupal\views\Tests\Plugin\DisplayPageWebTest.

Class

DisplayPageWebTest
Tests the views page display plugin as webtest.

Namespace

Drupal\views\Tests\Plugin

Code

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