You are here

public function BlockPluginHasSettingsTrayFormAccessCheckTest::providerTestAccess in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/settings_tray/tests/src/Unit/Access/BlockPluginHasSettingsTrayFormAccessCheckTest.php \Drupal\Tests\settings_tray\Unit\Access\BlockPluginHasSettingsTrayFormAccessCheckTest::providerTestAccess()
  2. 9 core/modules/settings_tray/tests/src/Unit/Access/BlockPluginHasSettingsTrayFormAccessCheckTest.php \Drupal\Tests\settings_tray\Unit\Access\BlockPluginHasSettingsTrayFormAccessCheckTest::providerTestAccess()

Provides test data for ::testAccess().

File

core/modules/settings_tray/tests/src/Unit/Access/BlockPluginHasSettingsTrayFormAccessCheckTest.php, line 47

Class

BlockPluginHasSettingsTrayFormAccessCheckTest
@coversDefaultClass \Drupal\settings_tray\Access\BlockPluginHasSettingsTrayFormAccessCheck @group settings_tray

Namespace

Drupal\Tests\settings_tray\Unit\Access

Code

public function providerTestAccess() {
  $annotation_forms_settings_tray_class = [
    'forms' => [
      'settings_tray' => $this
        ->randomMachineName(),
    ],
  ];
  $annotation_forms_settings_tray_not_set = [];
  $annotation_forms_settings_tray_false = [
    'forms' => [
      'settings_tray' => FALSE,
    ],
  ];
  return [
    'block plugin with forms, forms[settings_tray] set to class' => [
      TRUE,
      $annotation_forms_settings_tray_class,
      new AccessResultAllowed(),
    ],
    'block plugin with forms, forms[settings_tray] not set' => [
      TRUE,
      $annotation_forms_settings_tray_not_set,
      new AccessResultNeutral(),
    ],
    'block plugin with forms, forms[settings_tray] set to FALSE' => [
      TRUE,
      $annotation_forms_settings_tray_false,
      new AccessResultNeutral(),
    ],
    // In practice, all block plugins extend BlockBase, which means they all
    // implement PluginWithFormsInterface, but this may change in the future.
    // This ensures Settings Tray will continue to work correctly.
    'block plugin without forms, forms[settings_tray] set to class' => [
      FALSE,
      $annotation_forms_settings_tray_class,
      new AccessResultNeutral(),
    ],
    'block plugin without forms, forms[settings_tray] not set' => [
      FALSE,
      $annotation_forms_settings_tray_not_set,
      new AccessResultNeutral(),
    ],
    'block plugin without forms, forms[settings_tray] set to FALSE' => [
      FALSE,
      $annotation_forms_settings_tray_false,
      new AccessResultNeutral(),
    ],
  ];
}