public function BlockPluginHasSettingsTrayFormAccessCheckTest::testAccess in Drupal 10
Same name and namespace in other branches
- 8 core/modules/settings_tray/tests/src/Unit/Access/BlockPluginHasSettingsTrayFormAccessCheckTest.php \Drupal\Tests\settings_tray\Unit\Access\BlockPluginHasSettingsTrayFormAccessCheckTest::testAccess()
- 9 core/modules/settings_tray/tests/src/Unit/Access/BlockPluginHasSettingsTrayFormAccessCheckTest.php \Drupal\Tests\settings_tray\Unit\Access\BlockPluginHasSettingsTrayFormAccessCheckTest::testAccess()
@covers ::access @covers ::accessBlockPlugin @dataProvider providerTestAccess
File
- core/
modules/ settings_tray/ tests/ src/ Unit/ Access/ BlockPluginHasSettingsTrayFormAccessCheckTest.php, line 26
Class
- BlockPluginHasSettingsTrayFormAccessCheckTest
- @coversDefaultClass \Drupal\settings_tray\Access\BlockPluginHasSettingsTrayFormAccessCheck @group settings_tray
Namespace
Drupal\Tests\settings_tray\Unit\AccessCode
public function testAccess($with_forms, array $plugin_definition, AccessResultInterface $expected_access_result) {
$block_plugin = $this
->prophesize()
->willImplement(BlockPluginInterface::class);
if ($with_forms) {
$block_plugin
->willImplement(PluginWithFormsInterface::class);
$block_plugin
->hasFormClass(Argument::type('string'))
->will(function ($arguments) use ($plugin_definition) {
return !empty($plugin_definition['forms'][$arguments[0]]);
});
}
$block = $this
->prophesize(BlockInterface::class);
$block
->getPlugin()
->willReturn($block_plugin
->reveal());
$access_check = new BlockPluginHasSettingsTrayFormAccessCheck();
$this
->assertEquals($expected_access_result, $access_check
->access($block
->reveal()));
$this
->assertEquals($expected_access_result, $access_check
->accessBlockPlugin($block_plugin
->reveal()));
}