You are here

public function EntityAccessTest::testNeutralAccess in Open Social 8.5

Same name and namespace in other branches
  1. 8.9 modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  2. 8 modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  3. 8.2 modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  4. 8.3 modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  5. 8.4 modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  6. 8.6 modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  7. 8.7 modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  8. 8.8 modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  9. 10.3.x modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  10. 10.0.x modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  11. 10.1.x modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()
  12. 10.2.x modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php \Drupal\entity_access_by_field\Tests\EntityAccessTest::testNeutralAccess()

Tests the EntityAccessHelper::nodeAccessCheck for Neutral Access.

File

modules/custom/entity_access_by_field/tests/src/Unit/EntityAccessTest.php, line 18

Class

EntityAccessTest
Unit test of entity_access_by_field hook_node_access implementation.

Namespace

Drupal\entity_access_by_field\Tests

Code

public function testNeutralAccess() {
  $node = $this
    ->prophesize(NodeInterface::class);
  $this->fieldType = $this
    ->randomMachineName();
  $fieldDefinitionInterface = $this
    ->getMock('Drupal\\Core\\Field\\FieldDefinitionInterface');
  $fieldDefinitionInterface
    ->expects($this
    ->once())
    ->method('getType')
    ->willReturn($this->fieldType);
  $node
    ->getFieldDefinitions()
    ->willReturn([
    $this->fieldType => $fieldDefinitionInterface,
  ]);
  $node = $node
    ->reveal();
  $op = 'view';
  $account = $this
    ->prophesize(AccountInterface::class)
    ->reveal();
  $access_result = EntityAccessHelper::nodeAccessCheck($node, $op, $account);
  $this
    ->assertEquals(0, $access_result);
  $this
    ->assertNotEquals(2, $access_result);
  $this
    ->assertNotEquals(1, $access_result);
}