diff --git a/search_api_db/src/Tests/BackendTest.php b/search_api_db/src/Tests/BackendTest.php index b20e625..a0e87b0 100644 --- a/search_api_db/src/Tests/BackendTest.php +++ b/search_api_db/src/Tests/BackendTest.php @@ -17,6 +17,7 @@ use Drupal\search_api\Entity\Index; use Drupal\search_api\Entity\Server; use Drupal\search_api\Query\ResultSetInterface; use Drupal\search_api\Tests\ExampleContentTrait; +use Drupal\search_api\Utility; use Drupal\system\Tests\Entity\EntityUnitTestBase; use SebastianBergmann\Exporter\Exception; @@ -64,6 +65,8 @@ class BackendTest extends EntityUnitTestBase { $this->setUpExampleStructure(); $this->installConfig(array('search_api_test_db')); + + Utility::getIndexTaskManager()->addItemsAll(Index::load($this->indexId)); } /** diff --git a/src/Task/IndexTaskManager.php b/src/Task/IndexTaskManager.php index 864262d..cbb287a 100644 --- a/src/Task/IndexTaskManager.php +++ b/src/Task/IndexTaskManager.php @@ -143,14 +143,14 @@ class IndexTaskManager implements IndexTaskManagerInterface { /** @var \Drupal\search_api\IndexInterface $index */ $index = $this->entityManager->getStorage('search_api_index')->load($index_id); $added = $this->addItemsOnce($index); + if (!isset($context['results']['added'])) { + $context['results']['added'] = 0; + } if ($added === NULL) { $context['finished'] = 1; } else { $context['finished'] = 0; - if (!isset($context['results']['added'])) { - $context['results']['added'] = 0; - } $context['results']['added'] += $added; $args['%index'] = $index->label(); $context['message'] = $this->formatPlural($context['results']['added'], 'Tracked 1 item for the %index index.', 'Tracked @count items for the %index index.', $args); diff --git a/src/Tests/LanguageIntegrationUnitTest.php b/src/Tests/LanguageIntegrationUnitTest.php index 2c3d650..0876de2 100644 --- a/src/Tests/LanguageIntegrationUnitTest.php +++ b/src/Tests/LanguageIntegrationUnitTest.php @@ -11,6 +11,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\entity_test\Entity\EntityTestMul; use Drupal\search_api\Entity\Index; use Drupal\search_api\Entity\Server; +use Drupal\search_api\Utility; use Drupal\system\Tests\Entity\EntityLanguageTestBase; /** @@ -76,6 +77,8 @@ class LanguageIntegrationUnitTest extends EntityLanguageTestBase { 'options' => array('index_directly' => FALSE), )); $this->index->save(); + + Utility::getIndexTaskManager()->addItemsAll($this->index); } /** diff --git a/src/Tests/Processor/ContentAccessTest.php b/src/Tests/Processor/ContentAccessTest.php index e2fc710..75fd3da 100644 --- a/src/Tests/Processor/ContentAccessTest.php +++ b/src/Tests/Processor/ContentAccessTest.php @@ -112,6 +112,7 @@ class ContentAccessTest extends ProcessorTestBase { $this->index->set('datasources', array('entity:comment', 'entity:node', 'entity:user')); $this->index->save(); + Utility::getIndexTaskManager()->addItemsAll($this->index); $this->index = entity_load('search_api_index', $this->index->id(), TRUE); } diff --git a/src/Tests/ViewsTest.php b/src/Tests/ViewsTest.php index c0f45a3..04e6960 100644 --- a/src/Tests/ViewsTest.php +++ b/src/Tests/ViewsTest.php @@ -7,6 +7,9 @@ namespace Drupal\search_api\Tests; +use Drupal\search_api\Entity\Index; +use Drupal\search_api\Utility; + /** * Tests the Views integration of the Search API. * @@ -37,6 +40,8 @@ class ViewsTest extends WebTestBase { parent::setUp(); $this->setUpExampleStructure(); + + Utility::getIndexTaskManager()->addItemsAll(Index::load($this->indexId)); } /**