public function HierarchicalFacetIntegrationTest::setUp in Facets 8
Same name in this branch
- 8 tests/src/Functional/HierarchicalFacetIntegrationTest.php \Drupal\Tests\facets\Functional\HierarchicalFacetIntegrationTest::setUp()
- 8 modules/facets_summary/tests/src/Functional/HierarchicalFacetIntegrationTest.php \Drupal\Tests\facets_summary\Functional\HierarchicalFacetIntegrationTest::setUp()
Overrides FacetsTestBase::setUp
File
- tests/
src/ Functional/ HierarchicalFacetIntegrationTest.php, line 59
Class
- HierarchicalFacetIntegrationTest
- Tests the hierarchical facets implementation.
Namespace
Drupal\Tests\facets\FunctionalCode
public function setUp() {
parent::setUp();
$this
->drupalLogin($this->adminUser);
// Create hierarchical terms in a new vocabulary.
$this->vocabulary = $this
->createVocabulary();
$this
->createHierarchialTermStructure();
// Default content that is extended with a term reference field below.
$this
->setUpExampleStructure();
// Create a taxonomy_term_reference field on the article and item.
$this->fieldName = 'tax_ref_field';
$fieldLabel = 'Taxonomy reference field';
$this
->createEntityReferenceField('entity_test_mulrev_changed', 'article', $this->fieldName, $fieldLabel, 'taxonomy_term');
$this
->createEntityReferenceField('entity_test_mulrev_changed', 'item', $this->fieldName, $fieldLabel, 'taxonomy_term');
$this
->insertExampleContent();
// Add fields to index.
$index = $this
->getIndex();
// Index the taxonomy and entity reference fields.
$term_field = new Field($index, $this->fieldName);
$term_field
->setType('integer');
$term_field
->setPropertyPath($this->fieldName);
$term_field
->setDatasourceId('entity:entity_test_mulrev_changed');
$term_field
->setLabel($fieldLabel);
$index
->addField($term_field);
$index
->save();
$this
->indexItems($this->indexId);
$facet_name = 'hierarchical facet';
$facet_id = 'hierarchical_facet';
$this->facetEditPage = 'admin/config/search/facets/' . $facet_id . '/edit';
$this
->createFacet($facet_name, $facet_id, $this->fieldName);
// Make absolutely sure the ::$blocks variable doesn't pass information
// along between tests.
$this->blocks = NULL;
}