You are here

public function OgGroupContentOperationAccessTest::accessProvider in Organic groups 8

Data provider for ::testAccess().

Return value

array And array of test data sets. Each set consisting of:

  • A string representing the group content bundle ID upon which the operation is performed. Can be either 'newsletter' or 'article'.
  • An array mapping the different users and the possible operations, and whether or not the user is expected to be granted access to this operation, depending on whether they own the content or not.

File

tests/src/Kernel/Access/OgGroupContentOperationAccessTest.php, line 287

Class

OgGroupContentOperationAccessTest
Test access to group content operations for group members.

Namespace

Drupal\Tests\og\Kernel\Access

Code

public function accessProvider() {
  return [
    [
      'newsletter',
      [
        // The super user and the administrator have the right to create,
        // update and delete any newsletter subscription.
        'uid1' => [
          'create' => [
            'any' => TRUE,
          ],
          'update' => [
            'own' => TRUE,
            'any' => TRUE,
          ],
          'delete' => [
            'own' => TRUE,
            'any' => TRUE,
          ],
        ],
        OgRoleInterface::ADMINISTRATOR => [
          'create' => [
            'any' => TRUE,
          ],
          'update' => [
            'own' => TRUE,
            'any' => TRUE,
          ],
          'delete' => [
            'own' => TRUE,
            'any' => TRUE,
          ],
        ],
        // Non-members and members have the right to subscribe to the
        // newsletter, and to manage or delete their own newsletter
        // subscriptions.
        OgRoleInterface::ANONYMOUS => [
          'create' => [
            'any' => TRUE,
          ],
          'update' => [
            'own' => TRUE,
            'any' => FALSE,
          ],
          'delete' => [
            'own' => TRUE,
            'any' => FALSE,
          ],
        ],
        OgRoleInterface::AUTHENTICATED => [
          'create' => [
            'any' => TRUE,
          ],
          'update' => [
            'own' => TRUE,
            'any' => FALSE,
          ],
          'delete' => [
            'own' => TRUE,
            'any' => FALSE,
          ],
        ],
        // Blocked users cannot do anything, not even update or delete their
        // own content.
        'blocked' => [
          'create' => [
            'any' => FALSE,
          ],
          'update' => [
            'own' => FALSE,
            'any' => FALSE,
          ],
          'delete' => [
            'own' => FALSE,
            'any' => FALSE,
          ],
        ],
      ],
    ],
    [
      'article',
      [
        // The super user and the administrator have the right to create,
        // update and delete any article.
        'uid1' => [
          'create' => [
            'any' => TRUE,
          ],
          'update' => [
            'own' => TRUE,
            'any' => TRUE,
          ],
          'delete' => [
            'own' => TRUE,
            'any' => TRUE,
          ],
        ],
        OgRoleInterface::ADMINISTRATOR => [
          'create' => [
            'any' => TRUE,
          ],
          'update' => [
            'own' => TRUE,
            'any' => TRUE,
          ],
          'delete' => [
            'own' => TRUE,
            'any' => TRUE,
          ],
        ],
        // Non-members do not have the right to create or manage any article.
        OgRoleInterface::ANONYMOUS => [
          'create' => [
            'any' => FALSE,
          ],
          'update' => [
            'own' => FALSE,
            'any' => FALSE,
          ],
          'delete' => [
            'own' => FALSE,
            'any' => FALSE,
          ],
        ],
        // Members have the right to create new articles, and to manage their
        // own articles.
        OgRoleInterface::AUTHENTICATED => [
          'create' => [
            'any' => TRUE,
          ],
          'update' => [
            'own' => TRUE,
            'any' => FALSE,
          ],
          'delete' => [
            'own' => TRUE,
            'any' => FALSE,
          ],
        ],
        // Blocked users cannot do anything, not even update or delete their
        // own content.
        'blocked' => [
          'create' => [
            'any' => FALSE,
          ],
          'update' => [
            'own' => FALSE,
            'any' => FALSE,
          ],
          'delete' => [
            'own' => FALSE,
            'any' => FALSE,
          ],
        ],
      ],
    ],
  ];
}