BundlelessEntityTest.php in Search API 8
File
tests/src/Kernel/Datasource/BundlelessEntityTest.php
View source
<?php
namespace Drupal\Tests\search_api\Kernel\Datasource;
use Drupal\KernelTests\KernelTestBase;
use Drupal\search_api\Entity\Index;
class BundlelessEntityTest extends KernelTestBase {
protected $testEntityTypeId = 'user';
public static $modules = [
'search_api',
'user',
'system',
];
protected $index;
public function setUp() {
parent::setUp();
$this
->installEntitySchema('search_api_task');
$this
->installConfig([
'user',
]);
$this->index = Index::create([
'name' => 'Test Index',
'id' => 'test_index',
'status' => FALSE,
'datasource_settings' => [
'entity:' . $this->testEntityTypeId => [],
],
'tracker_settings' => [
'default' => [],
],
]);
$this->index
->save();
}
public function testViewModes() {
$datasource = $this->index
->getDatasource('entity:' . $this->testEntityTypeId);
$bundles = $datasource
->getBundles();
$expected = [
'user' => 'User',
];
$this
->assertEquals($expected, $bundles);
$view_modes = $datasource
->getViewModes('user');
$expected = [
'compact' => 'Compact',
'default' => 'Default',
'full' => 'User account',
];
ksort($view_modes);
$this
->assertEquals($expected, $view_modes);
$view_modes = $datasource
->getViewModes();
ksort($view_modes);
$this
->assertEquals($expected, $view_modes);
}
}