You are here

public function PanelizerFieldPanelsStorageTest::testAccessChangeContent in Panelizer 8.3

Same name and namespace in other branches
  1. 8.5 tests/src/Unit/PanelizerFieldPanelsStorageTest.php \Drupal\Tests\panelizer\Unit\PanelizerFieldPanelsStorageTest::testAccessChangeContent()
  2. 8.4 tests/src/Unit/PanelizerFieldPanelsStorageTest.php \Drupal\Tests\panelizer\Unit\PanelizerFieldPanelsStorageTest::testAccessChangeContent()

@covers ::access

File

tests/src/Unit/PanelizerFieldPanelsStorageTest.php, line 237

Class

PanelizerFieldPanelsStorageTest
Tests the PanelizerFieldPanelsStorage service.

Namespace

Drupal\Tests\panelizer\Unit

Code

public function testAccessChangeContent() {
  $panels_display = $this
    ->prophesize(PanelsDisplayVariant::class);
  $account = $this
    ->prophesize(AccountInterface::class);
  $entity = $this
    ->prophesize(FieldableEntityInterface::class);
  $entity
    ->access('update', $account
    ->reveal(), TRUE)
    ->willReturn(AccessResult::allowed());
  $this->storage
    ->load('123')
    ->willReturn($entity
    ->reveal());
  $this->panelizer
    ->getPanelsDisplay($entity
    ->reveal(), 'view_mode')
    ->willReturn($panels_display
    ->reveal());
  $this->panelizer
    ->hasEntityPermission('change content', $entity
    ->reveal(), 'view_mode', $account
    ->reveal())
    ->willReturn(TRUE);
  $access = $this->panelsStorage
    ->access('entity_type_id:123:view_mode', 'update', $account
    ->reveal());
  $this
    ->assertEquals(AccessResult::allowed(), $access);
}