You are here

public function GroupPermissionCheckerTest::provideHasPermissionInGroupScenarios in Group 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Unit/GroupPermissionCheckerTest.php \Drupal\Tests\group\Unit\GroupPermissionCheckerTest::provideHasPermissionInGroupScenarios()

Data provider for testHasPermissionInGroup().

All scenarios assume group ID 1 and type 'foo'.

File

tests/src/Unit/GroupPermissionCheckerTest.php, line 98

Class

GroupPermissionCheckerTest
Tests the group permission checker service.

Namespace

Drupal\Tests\group\Unit

Code

public function provideHasPermissionInGroupScenarios() {
  $scenarios['anonymousWithBypass'] = [
    TRUE,
    TRUE,
    [],
    [],
    'view group',
    TRUE,
    'An anonymous user with the bypass permission can view the group.',
  ];
  $scenarios['authenticatedWithBypass'] = [
    TRUE,
    FALSE,
    [],
    [],
    'view group',
    TRUE,
    'An authenticated user with the bypass permission can view the group.',
  ];
  $scenarios['anonymousWithAdmin'] = [
    FALSE,
    TRUE,
    [
      'foo' => [
        'administer group',
      ],
    ],
    [],
    'view group',
    TRUE,
    'An anonymous user with the group admin permission can view the group.',
  ];
  $scenarios['outsiderWithAdmin'] = [
    FALSE,
    FALSE,
    [
      'foo' => [
        'administer group',
      ],
    ],
    [],
    'view group',
    TRUE,
    'An outsider with the group admin permission can view the group.',
  ];
  $scenarios['memberWithAdmin'] = [
    FALSE,
    FALSE,
    [],
    [
      1 => [
        'administer group',
      ],
    ],
    'view group',
    TRUE,
    'A member with the group admin permission can view the group.',
  ];
  $scenarios['anonymousWithPermission'] = [
    FALSE,
    TRUE,
    [
      'foo' => [
        'view group',
      ],
    ],
    [],
    'view group',
    TRUE,
    'An anonymous user with the right permission can view the group.',
  ];
  $scenarios['outsiderWithPermission'] = [
    FALSE,
    FALSE,
    [
      'foo' => [
        'view group',
      ],
    ],
    [],
    'view group',
    TRUE,
    'An outsider with the right permission can view the group.',
  ];
  $scenarios['memberWithPermission'] = [
    FALSE,
    FALSE,
    [],
    [
      1 => [
        'view group',
      ],
    ],
    'view group',
    TRUE,
    'A member with the right permission can view the group.',
  ];
  $scenarios['anonymousWithoutPermission'] = [
    FALSE,
    TRUE,
    [
      'foo' => [],
    ],
    [],
    'view group',
    FALSE,
    'An anonymous user without the right permission can not view the group.',
  ];
  $scenarios['outsiderWithoutPermission'] = [
    FALSE,
    FALSE,
    [
      'foo' => [],
    ],
    [],
    'view group',
    FALSE,
    'An outsider without the right permission can not view the group.',
  ];
  $scenarios['memberWithoutPermission'] = [
    FALSE,
    FALSE,
    [],
    [
      1 => [],
    ],
    'view group',
    FALSE,
    'A member without the right permission can not view the group.',
  ];
  return $scenarios;
}