You are here

public function SearchApiSolrTest::regressionTest2850160 in Search API Solr 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/SearchApiSolrTest.php \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrTest::regressionTest2850160()

Regression tests for #2850160.

1 call to SearchApiSolrTest::regressionTest2850160()
SearchApiSolrTest::backendSpecificRegressionTests in tests/src/Kernel/SearchApiSolrTest.php
Runs backend specific regression tests.

File

tests/src/Kernel/SearchApiSolrTest.php, line 263

Class

SearchApiSolrTest
Tests index and search capabilities using the Solr search backend.

Namespace

Drupal\Tests\search_api_solr\Kernel

Code

public function regressionTest2850160() {

  // Only run the tests if we have a Solr core available.
  if ($this->solrAvailable) {
    $backend = Server::load($this->serverId)
      ->getBackend();
    $index = $this
      ->getIndex();

    // Load existing test entity.
    $entity = \Drupal::entityTypeManager()
      ->getStorage('entity_test_mulrev_changed')
      ->load(1);

    // Prepare Search API item.
    $id = Utility::createCombinedId('entity:entity_test_mulrev_changed', $entity
      ->id());

    /** @var \Drupal\search_api\Item\ItemInterface $item */
    $item = \Drupal::getContainer()
      ->get('search_api.fields_helper')
      ->createItemFromObject($index, $entity
      ->getTypedData(), $id);
    $item
      ->setBoost('3.0');

    // Get Solr document.

    /** @var \Solarium\QueryType\Update\Query\Document $document */
    $document = $this
      ->invokeMethod($backend, 'getDocument', [
      $index,
      $item,
    ]);

    // Compare boost values.
    $this
      ->assertEquals($item
      ->getBoost(), $document
      ->getBoost());
  }
}