ViewsTest.php in Search API Solr 8
File
tests/src/Functional/ViewsTest.php
View source
<?php
namespace Drupal\Tests\search_api_solr\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\search_api\Entity\Index;
use Drupal\Tests\search_api\Functional\SearchApiBrowserTestBase;
use Drupal\Tests\search_api\Functional\ViewsTest as SearchApiViewsTest;
use Drupal\search_api_solr\Utility\SolrCommitTrait;
class ViewsTest extends SearchApiViewsTest {
use SolrCommitTrait;
public static $modules = array(
'search_api_solr_test',
);
public function setUp() {
SearchApiBrowserTestBase::setUp();
ConfigurableLanguage::createFromLangcode('nl')
->save();
$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();
\Drupal::getContainer()
->get('search_api.index_task_manager')
->addItemsAll(Index::load($this->indexId));
$this
->insertExampleContent();
$this
->indexItems($this->indexId);
}
protected function tearDown() {
$index = Index::load($this->indexId);
$index
->clear();
$this
->ensureCommit($index);
parent::tearDown();
}
public function testSearchView() {
$query = [
'language' => [
'***LANGUAGE_language_interface***',
],
];
$this
->checkResults($query, [
1,
2,
3,
4,
5,
], 'Search with interface language as filter');
parent::testSearchView();
}
protected function indexItems($index_id) {
$index_status = parent::indexItems($index_id);
$index = Index::load($index_id);
$this
->ensureCommit($index);
return $index_status;
}
}
Classes
Name |
Description |
ViewsTest |
Tests the Views integration of the Search API. |