SolrFieldTypeTest.php in Search API Multilingual Solr Search 8
File
tests/src/Kernel/SolrFieldTypeTest.php
View source
<?php
namespace Drupal\Tests\search_api_solr_multilingual\Kernel;
use Drupal\Tests\SchemaCheckTestTrait;
use Drupal\config_test\TestInstallStorage;
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\TypedConfigManager;
use Drupal\KernelTests\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
class SolrFieldTypeTest extends KernelTestBase {
use SchemaCheckTestTrait;
protected $configNames = [];
protected $languageIds = [];
public static $modules = [
'language',
'search_api_solr_multilingual',
];
public function setUp() {
parent::setUp();
$this->configNames = array_keys(\Drupal::service('file_system')
->scanDirectory(drupal_get_path('module', 'search_api_solr_multilingual') . '/config', '/search_api_solr_multilingual.solr_field_type.text_/', [
'key' => 'name',
]));
foreach ($this->configNames as $config_name) {
preg_match('/search_api_solr_multilingual.solr_field_type.text_(.*)_\\d+_\\d+_\\d+/', $config_name, $matches);
$this->languageIds[] = $matches[1];
}
$this->languageIds = array_unique($this->languageIds);
foreach ($this->languageIds as $language_id) {
if ('und' != $language_id) {
ConfigurableLanguage::createFromLangcode($language_id)
->save();
}
}
}
public function testDefaultConfig() {
$typed_config = new TypedConfigManager(\Drupal::service('config.storage'), new TestInstallStorage(InstallStorage::CONFIG_SCHEMA_DIRECTORY), \Drupal::service('cache.discovery'), \Drupal::service('module_handler'));
$default_config_storage = new TestInstallStorage('test_search_api_solr_multilingual');
foreach ($this->configNames as $config_name) {
$data = $default_config_storage
->read($config_name);
$this
->assertConfigSchema($typed_config, $config_name, $data);
}
}
}