public function FacetFacetSourceTest::testDataDefinitions in Facets 8
Test the data definitions.
@covers \Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay::getDataDefinition
File
- tests/
src/ Kernel/ Entity/ FacetFacetSourceTest.php, line 199
Class
- FacetFacetSourceTest
- Class FacetFacetSourceTest.
Namespace
Drupal\Tests\facets\Kernel\EntityCode
public function testDataDefinitions() {
// Create and configure facet.
$entity = new Facet([], 'facets_facet');
$display_name = 'search_api:views_page__search_api_test_view__page_1';
$entity
->setFacetSourceId($display_name);
$this
->assertInstanceOf(DataDefinitionInterface::class, $entity
->getFacetSource()
->getDataDefinition('id'));
$this
->assertInstanceOf(DataDefinitionInterface::class, $entity
->getFacetSource()
->getDataDefinition('name'));
$this
->assertInstanceOf(DataDefinitionInterface::class, $entity
->getFacetSource()
->getDataDefinition('category'));
// When trying to get a field that doesn't exist, an error should be thrown.
$this
->expectException(Exception::class);
$entity
->getFacetSource()
->getDataDefinition('llama');
}