You are here

public function QueryTest::testQueryCloning in Search API 8

Tests that queries can be cloned.

File

tests/src/Kernel/System/QueryTest.php, line 153

Class

QueryTest
Tests query functionality.

Namespace

Drupal\Tests\search_api\Kernel\System

Code

public function testQueryCloning() {
  $query = $this->index
    ->query();
  $this
    ->assertEquals(0, $query
    ->getResults()
    ->getResultCount());
  $cloned_query = clone $query;
  $cloned_query
    ->getResults()
    ->setResultCount(1);
  $this
    ->assertEquals(0, $query
    ->getResults()
    ->getResultCount());
  $this
    ->assertEquals(1, $cloned_query
    ->getResults()
    ->getResultCount());
}