GroupingSolrTest.php in Search API Grouping 8
File
tests/src/Unit/GroupingSolrTest.php
View source
<?php
namespace Drupal\Tests\search_api_grouping\Unit;
use Drupal\search_api\Query\Query;
use Drupal\search_api_grouping\Plugin\search_api\processor\Grouping;
use Drupal\Tests\search_api\Unit\Processor\ProcessorTestTrait;
use Drupal\Tests\UnitTestCase;
class GroupingSolrTest extends UnitTestCase {
use ProcessorTestTrait;
public function setUp() {
parent::setUp();
$this->processor = new Grouping([], 'grouping', []);
}
public function testPreProcessSearchQuery() {
$query = $this
->getMockBuilder(Query::class)
->disableOriginalConstructor()
->getMock();
$config = [
'grouping_fields' => [
'type' => 'type',
],
'truncate' => TRUE,
'group_limit' => 3,
'group_sort' => 'type',
];
$this->processor
->setConfiguration($config);
$query_option = [
'use_grouping' => TRUE,
'grouping_fields' => [
'type' => 'type',
],
'truncate' => TRUE,
'group_limit' => 3,
'group_sort' => [
'type' => 'asc',
],
];
$query
->expects($this
->once())
->method('setOption')
->with($this
->identicalTo('search_api_grouping'), $this
->identicalTo($query_option));
$this->processor
->preprocessSearchQuery($query);
}
}