class OgAccessTest in Organic groups 8
Tests access.
@group og @coversDefaultClass \Drupal\og\OgAccess
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait- class \Drupal\Tests\og\Unit\OgAccessTestBase- class \Drupal\Tests\og\Unit\OgAccessTest
 
 
- class \Drupal\Tests\og\Unit\OgAccessTestBase
Expanded class hierarchy of OgAccessTest
File
- tests/src/ Unit/ OgAccessTest.php, line 13 
Namespace
Drupal\Tests\og\UnitView source
class OgAccessTest extends OgAccessTestBase {
  /**
   * Tests access for a non-group related entity.
   *
   * @coversDefaultmethod ::userAccess
   * @dataProvider permissionsProvider
   */
  public function testUserAccessNotGroup($operation) {
    $this->groupTypeManager
      ->isGroup($this->entityTypeId, $this->bundle)
      ->willReturn(FALSE);
    $user_access = $this->ogAccess
      ->userAccess($this->group, $operation);
    $this
      ->assertTrue($user_access
      ->isNeutral());
  }
  /**
   * Tests access to entity.
   *
   * @coversDefaultmethod ::userAccess
   * @dataProvider permissionsProvider
   */
  public function testAccessByOperation($operation) {
    $user_access = $this->ogAccess
      ->userAccess($this->group, $operation, $this->user
      ->reveal());
    // We populate the allowed permissions cache in
    // OgAccessTestBase::setup().
    $condition = $operation == 'update group' ? $user_access
      ->isAllowed() : $user_access
      ->isNeutral();
    $this
      ->assertTrue($condition);
  }
  /**
   * Tests access by the super user, which is user ID 1.
   *
   * @coversDefaultmethod ::userAccess
   * @dataProvider permissionsProvider
   */
  public function testUserAccessUser1($operation) {
    $this->user
      ->id()
      ->willReturn(1);
    $user_access = $this->ogAccess
      ->userAccess($this->group, $operation, $this->user
      ->reveal());
    $this
      ->assertTrue($user_access
      ->isAllowed());
  }
  /**
   * Tests access by a group administrator.
   *
   * @coversDefaultmethod ::userAccess
   * @dataProvider permissionsProvider
   */
  public function testUserAccessAdminPermission($operation) {
    $this->user
      ->hasPermission('administer organic groups')
      ->willReturn(TRUE);
    $user_access = $this->ogAccess
      ->userAccess($this->group, $operation, $this->user
      ->reveal());
    $this
      ->assertTrue($user_access
      ->isAllowed());
  }
  /**
   * Tests access by the owner of the entity.
   *
   * @coversDefaultmethod ::userAccess
   * @dataProvider permissionsProvider
   */
  public function testUserAccessOwner($operation) {
    $this->config
      ->get('group_manager_full_access')
      ->willReturn(TRUE);
    $user_access = $this->ogAccess
      ->userAccess($this
      ->groupEntity(TRUE)
      ->reveal(), $operation, $this->user
      ->reveal());
    $this
      ->assertTrue($user_access
      ->isAllowed());
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| OgAccessTest:: | public | function | Tests access to entity. | |
| OgAccessTest:: | public | function | Tests access by a group administrator. | |
| OgAccessTest:: | public | function | Tests access for a non-group related entity. | |
| OgAccessTest:: | public | function | Tests access by the owner of the entity. | |
| OgAccessTest:: | public | function | Tests access by the super user, which is user ID 1. | |
| OgAccessTestBase:: | protected | property | The bundle ID of the test group. | |
| OgAccessTestBase:: | protected | property | The mocked config handler. | |
| OgAccessTestBase:: | protected | property | The entity type ID of the test group. | |
| OgAccessTestBase:: | protected | property | The entity type manager service. | |
| OgAccessTestBase:: | protected | property | The mocked test group. | |
| OgAccessTestBase:: | protected | property | The ID of the test group. | |
| OgAccessTestBase:: | protected | property | The mocked group manager. | |
| OgAccessTestBase:: | protected | property | The membership entity. | |
| OgAccessTestBase:: | protected | property | The group membership manager service. | |
| OgAccessTestBase:: | protected | property | The OgAccess class, this is the system under test. | |
| OgAccessTestBase:: | protected | property | The OG role. | |
| OgAccessTestBase:: | protected | property | The mocked permission manager. | |
| OgAccessTestBase:: | protected | property | A mocked test user. | |
| OgAccessTestBase:: | protected | function | Mocks the cache methods. | |
| OgAccessTestBase:: | protected | function | Returns a mocked test group. | |
| OgAccessTestBase:: | public | function | Provides group level permissions to use in access tests. | |
| OgAccessTestBase:: | protected | function | Overrides UnitTestCase:: | 1 | 
| PhpunitCompatibilityTrait:: | public | function | Returns a mock object for the specified class using the available method. | |
| PhpunitCompatibilityTrait:: | public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
| UnitTestCase:: | protected | property | The random generator. | |
| UnitTestCase:: | protected | property | The app root. | 1 | 
| UnitTestCase:: | protected | function | Asserts if two arrays are equal by sorting them first. | |
| UnitTestCase:: | protected | function | Mocks a block with a block plugin. | 1 | 
| UnitTestCase:: | protected | function | Returns a stub class resolver. | |
| UnitTestCase:: | public | function | Returns a stub config factory that behaves according to the passed array. | |
| UnitTestCase:: | public | function | Returns a stub config storage that returns the supplied configuration. | |
| UnitTestCase:: | protected | function | Sets up a container with a cache tags invalidator. | |
| UnitTestCase:: | protected | function | Gets the random generator for the utility methods. | |
| UnitTestCase:: | public | function | Returns a stub translation manager that just returns the passed string. | |
| UnitTestCase:: | public | function | Generates a unique random string containing letters and numbers. | 
