SearchApiSortsUpdateBase.php in Search API sorts 8
File
tests/src/Functional/Update/SearchApiSortsUpdateBase.php
View source
<?php
namespace Drupal\Tests\search_api_sorts\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
abstract class SearchApiSortsUpdateBase extends UpdatePathTestBase {
public static $modules = [
'search_api_sorts',
'search_api_sorts_test_views',
];
public static $entityTypes = [
'search_api_index',
'search_api_server',
'search_api_task',
'search_api_sorts_field',
];
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.8.0.filled.standard.php.gz',
__DIR__ . '/../../../../../search_api/modules/search_api_db/tests/fixtures/update/search-api-db-base.php',
__DIR__ . '/../../../fixtures/update/search-api-sorts-db-base.php',
];
}
public function setUp() : void {
parent::setUp();
foreach ($this
->getEntityTypesFromClassProperty() as $entity_type_id) {
$entity_type = $this->container
->get('entity_type.manager')
->getDefinition($entity_type_id);
$this->container
->get('entity_type.listener')
->onEntityTypeCreate($entity_type);
}
}
protected function getEntityTypesFromClassProperty() {
$entity_types = [];
$class = get_class($this);
while ($class) {
if (property_exists($class, 'entityTypes')) {
$entity_types = array_merge($entity_types, $class::$entityTypes);
}
$class = get_parent_class($class);
}
return array_unique($entity_types);
}
}