function EntityArgumentTest::testArgumentTitle

Same name in other branches
  1. 10 core/modules/views/tests/src/Functional/Plugin/EntityArgumentTest.php \Drupal\Tests\views\Functional\Plugin\EntityArgumentTest::testArgumentTitle()

Tests the generated title of a view with an entity target argument.

File

core/modules/views/tests/src/Functional/Plugin/EntityArgumentTest.php, line 60

Class

EntityArgumentTest
Tests the handler of the view: entity target argument.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testArgumentTitle() : void {
    $view = Views::getView('test_entity_id_argument');
    $assert_session = $this->assertSession();
    // Test with single entity ID examples.
    $this->drupalGet('/entity-id-argument-test');
    $assert_session->titleEquals($view->getTitle() . ' | Drupal');
    $this->drupalGet('/entity-id-argument-test/1');
    $assert_session->titleEquals('test: title ' . $this->term1
        ->label() . ', input ' . $this->term1
        ->id() . ' | Drupal');
    $this->drupalGet('/entity-id-argument-test/2');
    $assert_session->titleEquals('test: title ' . $this->term2
        ->label() . ', input ' . $this->term2
        ->id() . ' | Drupal');
    // Test with multiple entity IDs examples.
    $this->drupalGet('/entity-id-argument-test/1,2');
    $assert_session->titleEquals('test: title ' . $this->term1
        ->label() . ', ' . $this->term2
        ->label() . ', input ' . $this->term1
        ->id() . ',' . $this->term2
        ->id() . ' | Drupal');
    $this->drupalGet('/entity-id-argument-test/2,1');
    $assert_session->titleEquals('test: title ' . $this->term2
        ->label() . ', ' . $this->term1
        ->label() . ', input ' . $this->term2
        ->id() . ',' . $this->term1
        ->id() . ' | Drupal');
    $this->drupalGet('/entity-id-argument-test/1+2');
    $assert_session->titleEquals('test: title ' . $this->term1
        ->label() . ' + ' . $this->term2
        ->label() . ', input ' . $this->term1
        ->id() . '+' . $this->term2
        ->id() . ' | Drupal');
    $this->drupalGet('/entity-id-argument-test/2+1');
    $assert_session->titleEquals('test: title ' . $this->term2
        ->label() . ' + ' . $this->term1
        ->label() . ', input ' . $this->term2
        ->id() . '+' . $this->term1
        ->id() . ' | Drupal');
}

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