FieldIntegrationTest.php in Search API 8
File
tests/src/Functional/FieldIntegrationTest.php
View source
<?php
namespace Drupal\Tests\search_api\Functional;
use Drupal\Core\Serialization\Yaml;
use Drupal\search_api\Entity\Index;
class FieldIntegrationTest extends SearchApiBrowserTestBase {
public static $modules = [
'entity_test',
'search_api_test_db',
];
public function testFields() {
$index = Index::load('database_search_index');
$fields = $index
->getFields();
$yaml_file = __DIR__ . '/../../search_api_test_db/config/install/search_api.index.database_search_index.yml';
$index_configuration = Yaml::decode(file_get_contents($yaml_file));
$field_settings = $index_configuration['field_settings'];
$this
->assertEquals(array_keys($fields), array_keys($field_settings));
foreach ($field_settings as $setting) {
$this
->assertArrayHasKey($setting['property_path'], $fields);
$field = $fields[$setting['property_path']];
$this
->assertEquals($setting['label'], $field
->getLabel());
$this
->assertEquals($setting['datasource_id'], $field
->getDatasourceId());
$this
->assertEquals($setting['type'], $field
->getType());
}
}
}