diff --git a/src/Entity/Index.php b/src/Entity/Index.php index c642d30..6fc0752 100644 --- a/src/Entity/Index.php +++ b/src/Entity/Index.php @@ -294,7 +294,8 @@ class Index extends ConfigEntityBase implements IndexInterface { if (empty($datasources[$datasource_id])) { $args['@datasource'] = $datasource_id; $args['%index'] = $this->label(); - throw new SearchApiException(new FormattableMarkup('The datasource with ID "@datasource" could not be retrieved for index %index.', $args)); + $args['@all_datasources'] = implode(', ', array_keys($datasources)); + throw new SearchApiException(new FormattableMarkup('The datasource with ID "@datasource" could not be retrieved for index %index. The available datasources are: @all_datasources', $args)); } return $datasources[$datasource_id]; } @@ -371,6 +372,10 @@ class Index extends ConfigEntityBase implements IndexInterface { * {@inheritdoc} */ public function getTrackerInstance() { + if ($this->getTrackerSettings() === NULL) { + return NULL; + } + if (!$this->trackerInstance) { if ($this->getTrackerSettings() === array()) { $tracker_settings = array( diff --git a/src/Tests/IntegrationTest.php b/src/Tests/IntegrationTest.php index c29f378..bf81971 100644 --- a/src/Tests/IntegrationTest.php +++ b/src/Tests/IntegrationTest.php @@ -98,6 +98,53 @@ class IntegrationTest extends WebTestBase { } /** + * Test what happens when an index has an integer as id/label. + * + * This needs to be in a seperate index because we also want to see what + * happens with the content and we don't want to mess with the content entity + * tracking of the other index. + */ + public function testIntegerIndex() { + $this->drupalLogin($this->adminUser); + $this->getTestServer(); + + $this->drupalCreateNode(array('type' => 'article')); + $this->drupalCreateNode(array('type' => 'article')); + + $this->drupalGet('admin/config/search/search-api/add-index'); + + $this->indexId = 123; + $edit = array( + 'name' => $this->indexId, + 'id' => $this->indexId, + 'status' => 1, + 'description' => 'test Index:: 123~', + 'server' => 'webtest_server', + 'datasources[]' => array('entity:node'), + ); + $this->drupalPostForm(NULL, $edit, $this->t('Save')); + $this->assertText($this->t('The index was successfully saved.')); + $this->assertText($this->t('Successfully tracked @count items for this index.', array('@count' => 2))); + $this->assertEqual(2, $this->countTrackedItems()); + + $this->enableAllProcessors(); + $this->checkFieldLabels(); + + $this->addFieldsToIndex(); + $this->removeFieldsFromIndex(); + + $this->configureFilter(); + $this->configureFilterPage(); + $this->checkProcessorChanges(); + $this->changeProcessorFieldBoost(); + + $this->setReadOnly(); + $this->disableEnableIndex(); + $this->changeIndexDatasource(); + $this->changeIndexServer(); + } + + /** * Tests creating a search server via the UI. */ protected function createServer($server_id = '_test_server') { diff --git a/src/Tests/Processor/ProcessorTestBase.php b/src/Tests/Processor/ProcessorTestBase.php index 4032312..abb60e6 100644 --- a/src/Tests/Processor/ProcessorTestBase.php +++ b/src/Tests/Processor/ProcessorTestBase.php @@ -87,9 +87,23 @@ abstract class ProcessorTestBase extends EntityUnitTestBase { 'id' => 'index', 'name' => 'Index name', 'status' => TRUE, - 'datasources' => array('entity:comment', 'entity:node'), + 'datasource_settings' => array( + 'entity:comment' => array( + 'plugin_id' => 'entity:comment', + 'settings' => array(), + ), + 'entity:node' => array( + 'plugin_id' => 'entity:node', + 'settings' => array(), + ), + ), 'server' => 'server', - 'tracker' => 'default', + 'tracker_settings' => array( + 'default' => array( + 'plugin_id' => 'default', + 'settings' => array() + ) + ), )); $this->index->setServer($this->server); $this->index->setFieldSettings(array(