public function ContentAccessTest::testAlterPropertyDefinitions in Search API 8
Tests whether the property is correctly added by the processor.
File
- tests/
src/ Kernel/ Processor/ ContentAccessTest.php, line 359
Class
- ContentAccessTest
- Tests the "Content access" processor.
Namespace
Drupal\Tests\search_api\Kernel\ProcessorCode
public function testAlterPropertyDefinitions() {
// Check for added properties when no datasource is given.
$properties = $this->processor
->getPropertyDefinitions(NULL);
$this
->assertArrayHasKey('search_api_node_grants', $properties, 'The Properties where modified with the "search_api_node_grants".');
$this
->assertInstanceOf(DataDefinitionInterface::class, $properties['search_api_node_grants'], 'The "search_api_node_grants" key contains a valid DataDefinition instance.');
$this
->assertEquals('string', $properties['search_api_node_grants']
->getDataType(), 'Correct DataType set in the DataDefinition.');
// Verify that there are no properties if a datasource is given.
$properties = $this->processor
->getPropertyDefinitions($this->index
->getDatasource('entity:node'));
$this
->assertEquals([], $properties, '"search_api_node_grants" property not added when datasource is given.');
}