FacetSourceTest.php in Facets 8
File
tests/src/Kernel/Entity/FacetSourceTest.php
View source
<?php
namespace Drupal\Tests\facets\Kernel\Entity;
use Drupal\facets\Entity\FacetSource;
use Drupal\KernelTests\KernelTestBase;
class FacetSourceTest extends KernelTestBase {
public static $modules = [
'facets',
];
public function setUp() {
parent::setUp();
$this
->installEntitySchema('facets_facet');
}
public function testConstruct() {
$fs = new FacetSource([
'id' => 'llama',
'name' => 'Llama',
'filter_key' => 'u',
'url_processor' => 'monkey',
], 'facets_facet_source');
$this
->assertEquals('u', $fs
->getFilterKey());
$this
->assertEquals('monkey', $fs
->getUrlProcessorName());
$this
->assertEquals('Llama', $fs
->getName());
}
public function testGetterSetters() {
$fs = new FacetSource([
'id' => 'llama',
], 'facets_facet_source');
$this
->assertNull($fs
->getFilterKey());
$this
->assertNull($fs
->getName());
$this
->assertEquals('query_string', $fs
->getUrlProcessorName());
$this
->assertEmpty($fs
->getBreadcrumbSettings());
$fs
->setFilterKey('ab');
$this
->assertEquals('ab', $fs
->getFilterKey());
$fs
->setUrlProcessor('test');
$this
->assertEquals('test', $fs
->getUrlProcessorName());
$breadcrumb_settings = [
'active' => 1,
'group' => 1,
];
$fs
->setBreadcrumbSettings($breadcrumb_settings);
$this
->assertEquals($breadcrumb_settings, $fs
->getBreadcrumbSettings());
}
}