You are here

public function ProcessorIntegrationTest::testListProcessor in Facets 8

Checks if the list processor changes machine name to the display label.

File

tests/src/Functional/ProcessorIntegrationTest.php, line 706

Class

ProcessorIntegrationTest
Tests the processor functionality.

Namespace

Drupal\Tests\facets\Functional

Code

public function testListProcessor() {
  entity_test_create_bundle('basic', "Basic page", 'entity_test_mulrev_changed');
  $entity_test_storage = \Drupal::entityTypeManager()
    ->getStorage('entity_test_mulrev_changed');

  // Add an entity with basic page content type.
  $entity_test_storage
    ->create([
    'name' => 'AC0871108',
    'body' => 'Eamus Catuli',
    'type' => 'basic',
  ])
    ->save();
  $this
    ->indexItems($this->indexId);
  $facet_name = "Eamus Catuli";
  $facet_id = "eamus_catuli";
  $editForm = 'admin/config/search/facets/' . $facet_id . '/edit';
  $this
    ->createFacet($facet_name, $facet_id);

  // Go to the overview and check that the machine names are used as facets.
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertSession()
    ->pageTextContains('Displaying 11 search results');
  $this
    ->assertFacetLabel('basic');

  // Edit the facet to use the list_item processor.
  $edit = [
    'facet_settings[list_item][status]' => TRUE,
  ];
  $this
    ->drupalPostForm($editForm, $edit, 'Save');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->checkboxChecked('edit-facet-settings-list-item-status');

  // Go back to the overview and check that now the label is being used
  // instead.
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertSession()
    ->pageTextContains('Displaying 11 search results');
  $this
    ->assertFacetLabel('Basic page');
}