You are here

protected function DefaultFacetManagerTest::createAndSaveFacet in Facets 8

Create and save a facet, for usage in test-scenario's.

Parameters

string $id: The id.

Return value

\Drupal\facets\FacetInterface The newly created facet.

2 calls to DefaultFacetManagerTest::createAndSaveFacet()
DefaultFacetManagerTest::testGetEnabledFacets in tests/src/Kernel/FacetManager/DefaultFacetManagerTest.php
Tests the getEnabledFacets method.
DefaultFacetManagerTest::testGetFacetsByFacetSourceId in tests/src/Kernel/FacetManager/DefaultFacetManagerTest.php
Tests the getFacetsByFacetSourceId method.

File

tests/src/Kernel/FacetManager/DefaultFacetManagerTest.php, line 114

Class

DefaultFacetManagerTest
Class DefaultFacetManagerTest.

Namespace

Drupal\Tests\facets\Kernel\FacetManager

Code

protected function createAndSaveFacet($id) {

  // Create a facet.
  $entity = Facet::create([
    'id' => $id,
    'name' => 'Test facet',
  ]);
  $entity
    ->setWidget('links');
  $entity
    ->setEmptyBehavior([
    'behavior' => 'none',
  ]);
  $entity
    ->setFacetSourceId('fluffy');
  $entity
    ->save();
  return $entity;
}