public function QueryTest::testGetOriginalQuery in Search API 8
Tests the getOriginalQuery() method.
File
- tests/src/ Kernel/ System/ QueryTest.php, line 230 
Class
- QueryTest
- Tests query functionality.
Namespace
Drupal\Tests\search_api\Kernel\SystemCode
public function testGetOriginalQuery() {
  $this
    ->getCalledMethods('backend');
  $query = $this->index
    ->query()
    ->addCondition('search_api_id', 2, '<>');
  $query_clone_1 = $query
    ->getOriginalQuery();
  $this
    ->assertEquals($query, $query_clone_1);
  $this
    ->assertNotSame($query, $query_clone_1);
  $query
    ->sort('search_api_id');
  $query_clone_2 = clone $query;
  $query
    ->execute();
  $methods = $this
    ->getCalledMethods('backend');
  $this
    ->assertEquals([
    'search',
  ], $methods);
  $this
    ->assertFalse($query_clone_1
    ->hasExecuted());
  $original_query = $query
    ->getOriginalQuery();
  $this
    ->assertEquals($query_clone_2, $original_query);
  $this
    ->assertFalse($original_query
    ->hasExecuted());
  $original_query
    ->execute();
  $methods = $this
    ->getCalledMethods('backend');
  $this
    ->assertEquals([
    'search',
  ], $methods);
}