RawTest.php in Search API Location 8
File
tests/src/Kernel/RawTest.php
View source
<?php
namespace Drupal\Tests\search_api_location\Kernel;
use Drupal\KernelTests\KernelTestBase;
class RawTest extends KernelTestBase {
public static $modules = [
'user',
'search_api',
'search_api_location',
];
protected $sut;
public function setUp() {
parent::setUp();
$this->sut = $this->container
->get('plugin.manager.search_api_location.location_input')
->createInstance('raw');
}
public function testValidParsedInput($valid, $expected) {
$input = [
'value' => $valid,
];
$parsedInput = $this->sut
->getParsedInput($input);
$this
->assertEquals($parsedInput, $expected);
}
public function testInvalidInput() {
$input = [
'value' => '^20.548,67.945',
];
$this
->assertNull($this->sut
->getParsedInput($input));
}
public function testWithUnexpectedInput() {
$input = [
'animal' => 'llama',
];
$this
->expectException(\InvalidArgumentException::class);
$this->sut
->getParsedInput($input);
}
public function provideValidInput() {
return [
'simple' => [
'20,67',
'20,67',
],
'with decimals' => [
'20.548,67.945',
'20.548,67.945',
],
'with spaces' => [
' 20.548,67.945',
'20.548,67.945',
],
];
}
}