You are here

public function UrlIntegrationTest::testColonValue in Facets 8

Tests the url when a colon is used in the value.

File

tests/src/Functional/UrlIntegrationTest.php, line 115

Class

UrlIntegrationTest
Tests the overall functionality of the Facets admin UI.

Namespace

Drupal\Tests\facets\Functional

Code

public function testColonValue() {
  $id = 'water_bear';
  $name = 'Water bear';
  $this
    ->createFacet($name, $id, 'keywords');

  // Add a new entity that has a colon in one of it's keywords.
  $entity_test_storage = \Drupal::entityTypeManager()
    ->getStorage('entity_test_mulrev_changed');
  $entity_test_storage
    ->create([
    'name' => 'Entity with colon',
    'body' => 'test test',
    'type' => 'item',
    'keywords' => [
      'orange',
      'test:colon',
    ],
    'category' => 'item_category',
  ])
    ->save();

  // Make sure the new item is indexed.
  $this
    ->assertEquals(1, $this
    ->indexItems($this->indexId));

  // Go to the overview and test that we have the expected links.
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertFacetLabel('test:colon');
  $this
    ->assertFacetLabel('orange');
  $this
    ->assertFacetLabel('banana');

  // Click the link with the colon.
  $this
    ->clickLink('test:colon');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Make sure 'test:colon' is active.
  $url = Url::fromUserInput('/search-api-test-fulltext', [
    'query' => [
      'f[0]' => 'water_bear:test:colon',
    ],
  ]);
  $this
    ->assertSession()
    ->addressEquals($url);
  $this
    ->checkFacetIsActive('test:colon');
  $this
    ->assertFacetLabel('orange');
  $this
    ->assertFacetLabel('banana');
}