View source
<?php
namespace Drupal\Tests\search_api\Unit\Processor;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\Item\Field;
use Drupal\search_api\Plugin\search_api\processor\IgnoreCase;
use Drupal\search_api\Query\Condition;
use Drupal\Tests\UnitTestCase;
class IgnoreCaseTest extends UnitTestCase {
use ProcessorTestTrait;
use TestItemsTrait;
protected function setUp() {
parent::setUp();
$this->processor = new IgnoreCase([], 'string', []);
}
public function testProcess($passed_value, $expected_value) {
$this
->invokeMethod('process', [
&$passed_value,
]);
$this
->assertEquals($passed_value, $expected_value);
}
public function processDataProvider() {
return [
[
'Foo bar',
'foo bar',
],
[
'foo Bar',
'foo bar',
],
[
'Foo Bar',
'foo bar',
],
[
'Foo bar BaZ, ÄÖÜÀÁ<>»«.',
'foo bar baz, äöüàá<>»«.',
],
];
}
public function testIsNullConditions() {
$this
->setUpMockContainer();
$index = $this
->createMock(IndexInterface::class);
$index
->method('getFields')
->willReturn([
'field' => (new Field($index, 'field'))
->setType('string'),
]);
$this->processor
->setIndex($index);
$passed_value = NULL;
$this
->invokeMethod('processConditionValue', [
&$passed_value,
]);
$this
->assertSame(NULL, $passed_value);
$condition = new Condition('field', NULL);
$conditions = [
$condition,
];
$this
->invokeMethod('processConditions', [
&$conditions,
]);
$this
->assertSame([
$condition,
], $conditions);
}
}