Commit b6f72b9b authored by borisson_'s avatar borisson_ Committed by borisson_

Issue #2884772 by borisson_, ruscoe, ashopin: Improve "List item processor"...

Issue #2884772 by borisson_, ruscoe, ashopin: Improve "List item processor" documentation, add test coverage for filtering by node type with underscores
parent 32fb92c9
......@@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* @FacetsProcessor(
* id = "list_item",
* label = @Translation("List item label"),
* description = @Translation("Display the label instead of the key of fields that are a list (such as <em>List (integer)</em>) or <em>List (text)</em>) or a bundle field."),
* description = @Translation("Display the label instead of the key of fields that are a list (such as <em>List (integer)</em>) or <em>List (text)</em>) or a bundle field. Keep in mind that transformations on the source of this field (such as transliteration or ignore characters) may break this functionality."),
* stages = {
* "build" = 5
* }
......
......@@ -844,4 +844,42 @@ class ProcessorIntegrationTest extends FacetsTestBase {
}
}
/**
* Tests the list item processor with underscores in the bundle.
*/
public function testEntityTranslateWithUnderScores() {
entity_test_create_bundle('test_with_underscore', "Test with underscore", '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' => 'llama',
'body' => 'llama.',
'type' => 'test_with_underscore',
])->save();
$this->indexItems($this->indexId);
$facet_id = 'owl';
$editForm = 'admin/config/search/facets/' . $facet_id . '/edit';
$this->createFacet('Owl', $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('test_with_underscore');
// Edit the facet to use the list_item processor.
$edit = [
'facet_settings[list_item][status]' => TRUE,
];
$this->drupalPostForm($editForm, $edit, 'Save');
// 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('Test with underscore');
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment