class IgnoreCaseTest in Search API 8
Tests the "Ignore case" processor.
@group search_api
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\search_api\Unit\Processor\IgnoreCaseTest uses ProcessorTestTrait, TestItemsTrait
Expanded class hierarchy of IgnoreCaseTest
See also
\Drupal\search_api\Plugin\search_api\processor\IgnoreCase
File
- tests/
src/ Unit/ Processor/ IgnoreCaseTest.php, line 18
Namespace
Drupal\Tests\search_api\Unit\ProcessorView source
class IgnoreCaseTest extends UnitTestCase {
use ProcessorTestTrait;
use TestItemsTrait;
/**
* Creates a new processor object for use in the tests.
*/
protected function setUp() {
parent::setUp();
$this->processor = new IgnoreCase([], 'string', []);
}
/**
* Tests the process() method.
*
* @param string $passed_value
* The value that should be passed into process().
* @param string $expected_value
* The expected processed value.
*
* @dataProvider processDataProvider
*/
public function testProcess($passed_value, $expected_value) {
$this
->invokeMethod('process', [
&$passed_value,
]);
$this
->assertEquals($passed_value, $expected_value);
}
/**
* Provides sets of arguments for testProcess().
*
* @return array[]
* Arrays of arguments for testProcess().
*/
public function processDataProvider() {
return [
[
'Foo bar',
'foo bar',
],
[
'foo Bar',
'foo bar',
],
[
'Foo Bar',
'foo bar',
],
[
'Foo bar BaZ, ÄÖÜÀÁ<>»«.',
'foo bar baz, äöüàá<>»«.',
],
];
}
/**
* Tests whether "IS NULL" conditions are correctly kept.
*
* @see https://www.drupal.org/project/search_api/issues/3212925
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IgnoreCaseTest:: |
public | function | Provides sets of arguments for testProcess(). | |
IgnoreCaseTest:: |
protected | function |
Creates a new processor object for use in the tests. Overrides UnitTestCase:: |
|
IgnoreCaseTest:: |
public | function | Tests whether "IS NULL" conditions are correctly kept. | |
IgnoreCaseTest:: |
public | function | Tests the process() method. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
ProcessorTestTrait:: |
protected | property | The tested processor. | |
ProcessorTestTrait:: |
protected | function | Invokes a method on the processor. | |
TestItemsTrait:: |
protected | property | The class container. | |
TestItemsTrait:: |
protected | property | The used item IDs for test items. | |
TestItemsTrait:: |
public | function | Creates a certain number of test items. | |
TestItemsTrait:: |
public | function | Creates an array with a single item which has the given field. | |
TestItemsTrait:: |
protected | function | Adds a container with several mock services commonly needed by our tests. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |