function BlockPluginHasSettingsTrayFormAccessCheckTest::testAccess

Same name in other branches
  1. 8.9.x core/modules/settings_tray/tests/src/Unit/Access/BlockPluginHasSettingsTrayFormAccessCheckTest.php \Drupal\Tests\settings_tray\Unit\Access\BlockPluginHasSettingsTrayFormAccessCheckTest::testAccess()
  2. 10 core/modules/settings_tray/tests/src/Unit/Access/BlockPluginHasSettingsTrayFormAccessCheckTest.php \Drupal\Tests\settings_tray\Unit\Access\BlockPluginHasSettingsTrayFormAccessCheckTest::testAccess()
  3. 11.x 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\Access

Code

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()));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.