public function IndexChangesTest::testFieldRenamed in Search API 8
Tests correct behavior when a field ID is changed.
File
- tests/
src/ Kernel/ Index/ IndexChangesTest.php, line 416
Class
- IndexChangesTest
- Tests correct reactions to changes for the index.
Namespace
Drupal\Tests\search_api\Kernel\IndexCode
public function testFieldRenamed() {
$datasource_id = 'entity:entity_test_mulrev_changed';
$info = [
'datasource_id' => $datasource_id,
'property_path' => 'name',
];
$field = \Drupal::getContainer()
->get('search_api.fields_helper')
->createField($this->index, 'name', $info);
$this->index
->addField($field);
$this
->assertEquals([], $this->index
->getFieldRenames());
$this->index
->renameField('name', 'name1');
$this
->assertEquals([
'name1' => $field,
], $this->index
->getFields());
$this
->assertEquals([
'name' => 'name1',
], $this->index
->getFieldRenames());
// Saving resets the field IDs.
$this->index
->save();
$this
->assertEquals([], $this->index
->getFieldRenames());
$this
->assertEquals('name1', $this->index
->getField('name1')
->getOriginalFieldIdentifier());
}