public function AddURLTest::testAlterPropertyDefinitions in Search API 8
Tests whether the properties are correctly altered.
See also
\Drupal\search_api\Plugin\search_api\processor\AddURL::alterPropertyDefinitions()
File
- tests/
src/ Unit/ Processor/ AddURLTest.php, line 120
Class
- AddURLTest
- Tests the "URL field" processor.
Namespace
Drupal\Tests\search_api\Unit\ProcessorCode
public function testAlterPropertyDefinitions() {
// Check for added properties when no datasource is given.
$properties = $this->processor
->getPropertyDefinitions(NULL);
$this
->assertArrayHasKey('search_api_url', $properties);
$this
->assertInstanceOf(AddURLProperty::class, $properties['search_api_url'], 'The "search_api_url" property contains a valid data definition.');
$this
->assertEquals('string', $properties['search_api_url']
->getDataType(), 'Correct data type set in the data definition.');
$this
->assertEquals('URI', $properties['search_api_url']
->getLabel(), 'Correct label set in the data definition.');
$this
->assertEquals('A URI where the item can be accessed', $properties['search_api_url']
->getDescription(), 'Correct description set in the data definition.');
// Verify that there are no properties if a datasource is given.
$datasource = $this
->createMock(DatasourceInterface::class);
$properties = $this->processor
->getPropertyDefinitions($datasource);
$this
->assertEmpty($properties, 'Datasource-specific properties did not get changed.');
}