You are here

public function RoleAccessTest::testAlterPropertyDefinitions in Search API 8

Tests whether the property is correctly added by the processor.

File

tests/src/Kernel/Processor/RoleAccessTest.php, line 227

Class

RoleAccessTest
Tests the "Role-based access" processor.

Namespace

Drupal\Tests\search_api\Kernel\Processor

Code

public function testAlterPropertyDefinitions() {

  // Check for added properties when no datasource is given.
  $properties = $this->processor
    ->getPropertyDefinitions(NULL);
  $this
    ->assertArrayHasKey('search_api_role_access', $properties);
  $property = $properties['search_api_role_access'];
  $this
    ->assertInstanceOf(DataDefinitionInterface::class, $property);
  $this
    ->assertEquals('string', $property
    ->getDataType());

  // Verify that there are no properties if a datasource is given.
  $datasource = $this->index
    ->getDatasource('entity:node');
  $properties = $this->processor
    ->getPropertyDefinitions($datasource);
  $this
    ->assertEquals([], $properties);
}