diff --git a/search_api_db/search_api_db_defaults/config/optional/search_api.index.default_index.yml b/search_api_db/search_api_db_defaults/config/optional/search_api.index.default_index.yml index 83090b9..6745379 100644 --- a/search_api_db/search_api_db_defaults/config/optional/search_api.index.default_index.yml +++ b/search_api_db/search_api_db_defaults/config/optional/search_api.index.default_index.yml @@ -7,7 +7,7 @@ fields: label: 'Item language' type: string property_path: search_api_language - index_locked: true + indexed_locked: true type_locked: true title: label: Title @@ -34,7 +34,7 @@ fields: type: boolean datasource_id: 'entity:node' property_path: status - index_locked: true + indexed_locked: true type_locked: true sticky: label: 'Sticky at top of lists' @@ -56,13 +56,13 @@ fields: type: integer datasource_id: 'entity:node' property_path: uid - index_locked: true + indexed_locked: true type_locked: true search_api_node_grants: label: 'Node access information' type: string property_path: search_api_node_grants - index_locked: true + indexed_locked: true type_locked: true hidden: true type: diff --git a/tests/search_api_test_db/config/install/search_api.index.database_search_index.yml b/tests/search_api_test_db/config/install/search_api.index.database_search_index.yml index 3404c09..72e1971 100644 --- a/tests/search_api_test_db/config/install/search_api.index.database_search_index.yml +++ b/tests/search_api_test_db/config/install/search_api.index.database_search_index.yml @@ -38,7 +38,7 @@ field_settings: label: 'Item language' type: string property_path: search_api_language - index_locked: true + indexed_locked: true type_locked: true processor_settings: add_url: diff --git a/tests/search_api_test_dependencies/src/Plugin/search_api/datasource/TestDatasource.php b/tests/search_api_test_dependencies/src/Plugin/search_api/datasource/TestDatasource.php index 739b9ff..58056ac 100644 --- a/tests/search_api_test_dependencies/src/Plugin/search_api/datasource/TestDatasource.php +++ b/tests/search_api_test_dependencies/src/Plugin/search_api/datasource/TestDatasource.php @@ -29,7 +29,10 @@ class TestDatasource extends DatasourcePluginBase { * {@inheritdoc} */ public function calculateDependencies() { - return $this->configuration['settings']; + if (isset($this->configuration['settings'])) { + return $this->configuration['settings']; + } + return array(); } /** diff --git a/tests/search_api_test_dependencies/src/Plugin/search_api/processor/TestProcessor.php b/tests/search_api_test_dependencies/src/Plugin/search_api/processor/TestProcessor.php index 5ce230c..01136fa 100644 --- a/tests/search_api_test_dependencies/src/Plugin/search_api/processor/TestProcessor.php +++ b/tests/search_api_test_dependencies/src/Plugin/search_api/processor/TestProcessor.php @@ -21,7 +21,10 @@ class TestProcessor extends ProcessorPluginBase { * {@inheritdoc} */ public function calculateDependencies() { - return $this->configuration; + if (isset($this->configuration)) { + return $this->configuration; + } + return array(); } /** diff --git a/tests/search_api_test_dependencies/src/Plugin/search_api/tracker/TestTracker.php b/tests/search_api_test_dependencies/src/Plugin/search_api/tracker/TestTracker.php index 6ac77d4..dd43a65 100644 --- a/tests/search_api_test_dependencies/src/Plugin/search_api/tracker/TestTracker.php +++ b/tests/search_api_test_dependencies/src/Plugin/search_api/tracker/TestTracker.php @@ -21,7 +21,10 @@ class TestTracker extends BasicTracker { * {@inheritdoc} */ public function calculateDependencies() { - return $this->configuration; + if (isset($this->configuration)) { + return $this->configuration; + } + return array(); } /** diff --git a/tests/src/Kernel/DependencyRemovalTest.php b/tests/src/Kernel/DependencyRemovalTest.php index 9702b43..2c23e62 100644 --- a/tests/src/Kernel/DependencyRemovalTest.php +++ b/tests/src/Kernel/DependencyRemovalTest.php @@ -48,6 +48,9 @@ class DependencyRemovalTest extends KernelTestBase { public function setUp() { parent::setUp(); + $this->installSchema('user', array('users_data')); + $this->installEntitySchema('user'); + // The server tasks manager is needed when removing a server. $mock = $this->getMock('Drupal\search_api\Task\ServerTaskManagerInterface'); $this->container->set('search_api.server_task_manager', $mock); @@ -60,7 +63,7 @@ class DependencyRemovalTest extends KernelTestBase { 'tracker_settings' => array( 'default' => array( 'plugin_id' => 'default', - 'setttings' => array(), + 'settings' => array(), ) ), 'datasource_settings' => array( @@ -222,15 +225,14 @@ class DependencyRemovalTest extends KernelTestBase { // Depending on whether the plugin should have removed the dependency or // not, make sure the right action was taken. - $datasources = $this->index->get('datasources'); - $datasource_configs = $this->index->get('datasource_configs'); + $datasource_settings = $this->index->get('datasource_settings'); + if ($remove_dependency) { - $this->assertContains('search_api_test_dependencies', $datasources, 'Datasource not removed'); - $this->assertEmpty($datasource_configs['search_api_test_dependencies'], 'Datasource settings adapted'); + $this->assertArrayHasKey('search_api_test_dependencies', $datasource_settings, 'Datasource not removed'); + $this->assertEmpty($datasource_settings['search_api_test_dependencies'], 'Datasource settings adapted'); } else { - $this->assertNotContains('search_api_test_dependencies', $datasources, 'Datasource removed'); - $this->assertArrayNotHasKey('search_api_test_dependencies', $datasource_configs, 'Datasource config removed'); + $this->assertArrayNotHasKey('search_api_test_dependencies', $datasource_settings, 'Datasource config removed'); } } @@ -323,13 +325,13 @@ class DependencyRemovalTest extends KernelTestBase { // Depending on whether the plugin should have removed the dependency or // not, make sure the right action was taken. - $processors = $this->index->get('processors'); + $processor_settings = $this->index->get('processor_settings'); if ($remove_dependency) { - $this->assertArrayHasKey('search_api_test_dependencies', $processors, 'Processor not removed'); - $this->assertEmpty($processors['search_api_test_dependencies']['settings'], 'Processor settings adapted'); + $this->assertArrayHasKey('search_api_test_dependencies', $processor_settings, 'Processor not removed'); + $this->assertEmpty($processor_settings['search_api_test_dependencies']['settings'], 'Processor settings adapted'); } else { - $this->assertArrayNotHasKey('search_api_test_dependencies', $processors, 'Processor removed'); + $this->assertArrayNotHasKey('search_api_test_dependencies', $processor_settings, 'Processor removed'); } } @@ -343,6 +345,9 @@ class DependencyRemovalTest extends KernelTestBase { * @dataProvider dependencyTestDataProvider */ public function testTrackerDependency($remove_dependency) { + // Set the server on the index and save that, too. + $this->index->set('server', $this->dependency->id()); + // Set the tracker for the index and save it. The tracker configuration // contains the dependencies it will return – in our case, we use the test // server. @@ -368,13 +373,12 @@ class DependencyRemovalTest extends KernelTestBase { // \Drupal\search_api_test_dependencies\Plugin\search_api\tracker\TestTracker::onDependencyRemoval(). $key = 'search_api_test_dependencies.tracker.remove'; \Drupal::state()->set($key, $remove_dependency); + // If the index resets the tracker, it needs to know the ID of the default // tracker. - if (!$remove_dependency) { - \Drupal::configFactory()->getEditable('search_api.settings') - ->set('default_tracker', 'default') - ->save(); - } + \Drupal::configFactory()->getEditable('search_api.settings') + ->set('default_tracker', 'default') + ->save(); // Delete the tracker's dependency. $this->dependency->delete(); @@ -391,10 +395,13 @@ class DependencyRemovalTest extends KernelTestBase { // Depending on whether the plugin should have removed the dependency or // not, make sure the right action was taken. $tracker_settings = $this->index->get('tracker_settings'); + + // Get first tracker in the list if there is a list. There should always + // be a tracker so there is no issue in taking the first key. $tracker = array_keys($tracker_settings)[0]; $tracker_config = $tracker_settings[$tracker]['settings']; - if ($remove_dependency) { + if (!$remove_dependency) { $this->assertEquals('search_api_test_dependencies', $tracker, 'Tracker not reset'); $this->assertEmpty($tracker_config, 'Tracker settings adapted'); }