public function FieldBlockTest::testBlockAccessEntityAllowedNoField in Drupal 9
Same name and namespace in other branches
- 8 core/modules/layout_builder/tests/src/Kernel/FieldBlockTest.php \Drupal\Tests\layout_builder\Kernel\FieldBlockTest::testBlockAccessEntityAllowedNoField()
- 10 core/modules/layout_builder/tests/src/Kernel/FieldBlockTest.php \Drupal\Tests\layout_builder\Kernel\FieldBlockTest::testBlockAccessEntityAllowedNoField()
Tests fieldable entity without a particular field.
@covers ::blockAccess
File
- core/
modules/ layout_builder/ tests/ src/ Kernel/ FieldBlockTest.php, line 112
Class
- FieldBlockTest
- @coversDefaultClass \Drupal\layout_builder\Plugin\Block\FieldBlock @group Field
Namespace
Drupal\Tests\layout_builder\KernelCode
public function testBlockAccessEntityAllowedNoField() {
$entity = $this
->prophesize(FieldableEntityInterface::class);
$block = $this
->getTestBlock($entity);
$account = $this
->prophesize(AccountInterface::class);
$entity
->access('view', $account
->reveal(), TRUE)
->willReturn(AccessResult::allowed());
$entity
->hasField('the_field_name')
->willReturn(FALSE);
$entity
->get('the_field_name')
->shouldNotBeCalled();
$access = $block
->access($account
->reveal(), TRUE);
$this
->assertFalse($access
->isAllowed());
}