You are here

public function PermissionEventTest::offsetSetInvalidPermissionProvider in Organic groups 8

Data provider for testOffsetSetInvalidPermission().

Return value

array An array of invalid test data, each set containing:

  • The array key to use when setting the permission though ArrayAccess.
  • The permission to set.

File

tests/src/Unit/PermissionEventTest.php, line 462

Class

PermissionEventTest
Tests permission events.

Namespace

Drupal\Tests\og\Unit

Code

public function offsetSetInvalidPermissionProvider() {
  return [
    // Test that an exception is thrown when setting a nameless permission.
    [
      '',
      new GroupPermission([
        'title' => $this
          ->t('A permission without a machine name.'),
      ]),
    ],
    // Test that an exception is thrown when setting permission without a
    // title.
    [
      '',
      new GroupPermission([
        'name' => 'a titleless permission',
      ]),
    ],
    // Test that an exception is thrown when the array key doesn't match the
    // machine name.
    [
      'a non-matching key',
      new GroupPermission([
        'name' => 'a different key',
        'title' => $this
          ->t('This permission has a name that differs from the array key that is used to set it.'),
      ]),
    ],
    // Test that an exception is thrown when an object is passed which is not
    // implementing \Drupal\og\PermissionInterface.
    [
      'a non-matching key',
      new \stdClass(),
    ],
  ];
}