You are here

class OpenAtriumAccessAllTestCase in Open Atrium Core 7.2

Functional tests for permissions that default to 'All' for the Open Atrium Access module.

Hierarchy

Expanded class hierarchy of OpenAtriumAccessAllTestCase

File

modules/oa_access/tests/oa_access.test, line 803
Functional tests for the Open Atrium Access module.

View source
class OpenAtriumAccessAllTestCase extends OpenAtriumAccessBaseTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Open Atrium Access (default "All" permissions)',
      'description' => 'Test permisisons that default to "All" in the Open Atrium Access API.',
      'group' => 'Open Atrium Access',
    );
  }
  public function testModuleEnableAndInitialize() {

    // First, make sure we don't have access.
    $this
      ->assertEqual($this
      ->getGroupPermissions('oa_access_test_all', array(
      0,
    )), array(
      0 => array(),
    ));

    // Then we enable the oa_access_test_all module and check again.
    module_enable(array(
      'oa_access_test_all',
    ));
    $this
      ->assertEqual($this
      ->getGroupPermissions('oa_access_test_all', array(
      0,
    )), array(
      0 => array(
        'oa_access_test_all' => array(
          'permission that defaults to all for oa_access_test_all',
        ),
      ),
    ));

    // Check that only the single permission is defined.
    $perms = array(
      'permission that defaults to all for oa_access_test_all' => array(
        'title' => t('A permission that defaults to the "All" option'),
        'description' => t('Used to test the functionality to default to the "All" option'),
        'type' => OA_ACCESS_DEFAULT_PERMISSION | OA_ACCESS_DEFAULT_OPTION_ALL,
        'module' => 'oa_access_test_all',
        'combine' => OA_ACCESS_COMBINE_UNION,
      ),
    );
    $this
      ->assertEqual($this
      ->getPermissions('oa_access_test_all'), $perms);

    // Now, we want to add a new permission and test that it's available.
    variable_set('oa_access_test_all_initialize_permissions', TRUE);
    $perms['a permission for oa_access_test_all that is added after install'] = array(
      'title' => t('Some fickle permission'),
      'description' => t('A permission for oa_access_test that is only conditionally available'),
      'type' => OA_ACCESS_DEFAULT_PERMISSION | OA_ACCESS_DEFAULT_OPTION_ALL,
      'module' => 'oa_access_test_all',
      'combine' => OA_ACCESS_COMBINE_UNION,
    );
    $this
      ->assertEqual($this
      ->getPermissions('oa_access_test_all', TRUE), $perms);

    // Next, we initialize it and check that the 'All' group has it.
    oa_access_initialize_permissions('a permission for oa_access_test_all that is added after install');
    $this
      ->assertEqual($this
      ->getGroupPermissions('oa_access_test_all', array(
      0,
    )), array(
      0 => array(
        'oa_access_test_all' => array(
          'a permission for oa_access_test_all that is added after install',
          'permission that defaults to all for oa_access_test_all',
        ),
      ),
    ));
  }
  public function testModuleEnableWithTeams() {

    // Create an admin user and login.
    $account = $this
      ->oaCreateUser(array(
      'create oa_space content',
    ));
    $this
      ->drupalLogin($account);

    // Create a Space that could hold teams some day.
    $space1 = $this
      ->oaCreateNode(array(
      'title' => 'Space A',
      'type' => 'oa_space',
      'uid' => $account->uid,
    ));

    // First, make sure we don't have access.
    $this
      ->assertEqual(oa_access_get_group_permissions(array(
      $space1->nid,
    )), array(
      $space1->nid => array(),
    ));

    // Then we enable the oa_access_test_all module and check again.
    module_enable(array(
      'oa_access_test_all',
    ));
    $this
      ->assertEqual(oa_access_get_group_permissions(array(
      $space1->nid,
    )), array(
      $space1->nid => array(
        'oa_access_test_all' => array(
          'permission that defaults to all for oa_access_test_all',
        ),
      ),
    ));
  }
  public function testAddSpaces() {

    // Straight off the bat, enable
    module_enable(array(
      'oa_access_test_all',
    ));

    // Create an admin user and login.
    $account = $this
      ->oaCreateUser(array(
      'create oa_space content',
    ));
    $this
      ->drupalLogin($account);

    // Create a new Space that could hold teams some day.
    $space1 = $this
      ->oaCreateNode(array(
      'title' => 'Space A',
      'type' => 'oa_space',
      'uid' => $account->uid,
    ));

    // Check that default access was added.
    $this
      ->assertEqual(oa_access_get_group_permissions(array(
      $space1->nid,
    )), array(
      $space1->nid => array(
        'oa_access_test_all' => array(
          'permission that defaults to all for oa_access_test_all',
        ),
      ),
    ));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
OpenAtriumAccessAllTestCase::getInfo public static function
OpenAtriumAccessAllTestCase::testAddSpaces public function
OpenAtriumAccessAllTestCase::testModuleEnableAndInitialize public function
OpenAtriumAccessAllTestCase::testModuleEnableWithTeams public function
OpenAtriumAccessBaseTestCase::$profile protected property
OpenAtriumAccessBaseTestCase::getGroupPermissions protected function Gets all the permissions that a list of groups have.
OpenAtriumAccessBaseTestCase::getPermissions protected function Get all permissions defined by implementing modules.
OpenAtriumAccessBaseTestCase::hasSelectOption function Check if a select has a certain option.
OpenAtriumAccessBaseTestCase::oaCreateGroupWithUser protected function Creates an Open Atrium Group with a new user in an optional Space.
OpenAtriumAccessBaseTestCase::oaCreateNode protected function Creates a node with an optional Space or Section.
OpenAtriumAccessBaseTestCase::oaCreateTeamWithUser protected function Creates an Open Atrium Team with a new user in a Space.
OpenAtriumAccessBaseTestCase::oaCreateUser protected function Create a user with an optional Space.
OpenAtriumAccessBaseTestCase::oaPostPermissions protected function Post to a Group/Team permisisons page with a set of values.
OpenAtriumAccessBaseTestCase::setUp public function 1