diff --git a/src/Plugin/search_api/datasource/ContentEntity.php b/src/Plugin/search_api/datasource/ContentEntity.php index 1d80e50..1d44c6c 100644 --- a/src/Plugin/search_api/datasource/ContentEntity.php +++ b/src/Plugin/search_api/datasource/ContentEntity.php @@ -622,8 +622,8 @@ class ContentEntity extends DatasourcePluginBase { } } else { - foreach ($configuration['languages'] as $langcode) { - $allowed_languages[$langcode] = $langcode; + foreach ($configuration['languages'] as $langcode => $checked) { + $allowed_languages[$langcode] = $all_languages[$langcode]; } } diff --git a/src/Tests/IndexIntegrationTest.php b/src/Tests/IndexIntegrationTest.php index 491e004..a6478b9 100644 --- a/src/Tests/IndexIntegrationTest.php +++ b/src/Tests/IndexIntegrationTest.php @@ -86,17 +86,34 @@ class IndexIntegrationTest extends WebTestBase { $this->assertEqual($tracked_items, 5, 'Five items are tracked.'); // Change the datasource to disallow indexing of dutch. + $form_values = array('datasource_configs[entity:node][languages][nl]' => 1); $this->drupalGet($this->getIndexPath('edit')); - $this->drupalPostForm(NULL, array(), $this->t('Configure')); - $this->drupalPostForm(NULL, array('datasource_configs[entity:node][languages][nl]' => 1), $this->t('Save')); + $this->drupalPostForm(NULL, $form_values, $this->t('Save')); $this->assertResponse(200); $this->assertText('The index was successfully saved.'); - // Make sure that we only have 3 indexed items now. The 2 original nodes // + 1 translation in lolspeak, the 2 dutch translations should be ignored. - $tracked_items = $this->countTrackedItems(); - $this->assertEqual($tracked_items, 3, 'Three items are tracked.'); + $this->drupalGet($this->getIndexPath()); + $this->drupalPostForm(NULL, array(), $this->t('Index now')); + $this->assertText($this->t('Successfully indexed 3 items')); + + // Change the datasource to only allow indexing of dutch. + $form_values = array( + 'datasource_configs[entity:node][default]' => 0, + 'datasource_configs[entity:node][bundles][article]' => 1, + 'datasource_configs[entity:node][languages][nl]' => 1, + ); + $this->drupalGet($this->getIndexPath('edit')); + $this->drupalPostForm(NULL, $form_values, $this->t('Save')); + $this->assertResponse(200); + $this->assertText('The index was successfully saved.'); + + // Make sure that we only have 2 index items. The only indexed items should + // be the dutch translations. + $this->drupalGet($this->getIndexPath()); + $this->drupalPostForm(NULL, array(), $this->t('Index now')); + $this->assertText($this->t('Successfully indexed 2 items')); } /**