public function ViewsTest::setUp in Search API Solr 4.x
Same name and namespace in other branches
- 8.3 tests/src/Functional/ViewsTest.php \Drupal\Tests\search_api_solr\Functional\ViewsTest::setUp()
- 8 tests/src/Functional/ViewsTest.php \Drupal\Tests\search_api_solr\Functional\ViewsTest::setUp()
- 8.2 tests/src/Functional/ViewsTest.php \Drupal\Tests\search_api_solr\Functional\ViewsTest::setUp()
File
- tests/
src/ Functional/ ViewsTest.php, line 31
Class
- ViewsTest
- Tests the Views integration of the Search API.
Namespace
Drupal\Tests\search_api_solr\FunctionalCode
public function setUp() : void {
// Skip parent::setUp().
SearchApiBrowserTestBase::setUp();
// Add a second language.
ConfigurableLanguage::createFromLangcode('nl')
->save();
// Swap database backend for Solr backend.
$config_factory = \Drupal::configFactory();
$config_factory
->getEditable('search_api.index.database_search_index')
->delete();
$config_factory
->rename('search_api.index.solr_search_index', 'search_api.index.database_search_index');
$config_factory
->getEditable('search_api.index.database_search_index')
->set('id', 'database_search_index')
->save();
$this
->adjustBackendConfig();
// Now do the same as parent::setUp().
\Drupal::getContainer()
->get('search_api.index_task_manager')
->addItemsAll(Index::load($this->indexId));
$this
->insertExampleContent();
$this
->indexItems($this->indexId);
// Do not use a batch for tracking the initial items after creating an
// index when running the tests via the GUI. Otherwise, it seems Drupal's
// Batch API gets confused and the test fails.
if (!Utility::isRunningInCli()) {
\Drupal::state()
->set('search_api_use_tracking_batch', FALSE);
}
}