You are here

public function FacetTest::testHierarchySettings in Facets 8

Tests hierarchy settings.

@covers ::getHierarchy @covers ::setUseHierarchy @covers ::getUseHierarchy @covers ::setExpandHierarchy @covers ::getExpandHierarchy @covers ::setEnableParentWhenChildGetsDisabled @covers ::getEnableParentWhenChildGetsDisabled @covers ::getHierarchyManager @covers ::getHierarchyInstance

File

tests/src/Kernel/Entity/FacetTest.php, line 365

Class

FacetTest
Class FacetTest.

Namespace

Drupal\Tests\facets\Kernel\Entity

Code

public function testHierarchySettings() {
  $entity = Facet::create();
  $entity
    ->setUseHierarchy(FALSE);
  $this
    ->assertFalse($entity
    ->getUseHierarchy());
  $entity
    ->setUseHierarchy(TRUE);
  $this
    ->assertTrue($entity
    ->getUseHierarchy());
  $entity
    ->setExpandHierarchy(FALSE);
  $this
    ->assertFalse($entity
    ->getExpandHierarchy());
  $entity
    ->setExpandHierarchy(TRUE);
  $this
    ->assertTrue($entity
    ->getExpandHierarchy());
  $entity
    ->setEnableParentWhenChildGetsDisabled(FALSE);
  $this
    ->assertFalse($entity
    ->getEnableParentWhenChildGetsDisabled());
  $entity
    ->setEnableParentWhenChildGetsDisabled(TRUE);
  $this
    ->assertTrue($entity
    ->getEnableParentWhenChildGetsDisabled());
  $manager = $entity
    ->getHierarchyManager();
  $this
    ->assertInstanceOf(HierarchyPluginManager::class, $manager);
  $this
    ->assertInstanceOf(Taxonomy::class, $entity
    ->getHierarchyInstance());
  $this
    ->assertEquals([
    'type' => 'taxonomy',
    'config' => [],
  ], $entity
    ->getHierarchy());
}