You are here

public function AccessGrantFunctionTest::testGrantRender in Access Control Kit 7

Test the access grant rendering functions.

File

./access.test, line 1212
Tests for the access control kit module.

Class

AccessGrantFunctionTest
Tests for access grant functions.

Code

public function testGrantRender() {
  $gids = array(
    $this->grants[0]->gid,
    $this->grants[1]->gid,
  );
  $loaded_grants = access_grant_load_multiple($gids);
  $render = access_grant_view_multiple($loaded_grants, 'full', 3);

  // Check weight and sorting.
  $this
    ->assertEqual($render['grants'][$gids[0]]['#weight'], 3, 'Rendered weight is correct.');
  $this
    ->assertEqual($render['grants'][$gids[1]]['#weight'], 4, 'Rendered weight increments.');
  $this
    ->assertTrue($render['grants']['#sorted'], 'Rendered grants are sorted.');

  // Check the renderable array.
  $this
    ->assertEqual($render['grants'][$gids[0]]['#theme'], 'access_grant', 'Rendered grants are themed.');
  $this
    ->assertEqual($render['grants'][$gids[0]]['#view_mode'], 'full', 'Grants are rendered in full mode.');
  $this
    ->assertEqual($render['grants'][$gids[0]]['#access_grant']->gid, $gids[0], 'Grant object is included in the renderable array.');

  // Check attached fields and pseudo-fields.
  $this
    ->assertEqual($render['grants'][$gids[0]]['#bundle'], $this->scheme->machine_name, 'The bundle property is attached.');
  $this
    ->assertTrue(isset($render['grants'][$gids[0]]['user']), 'The user property is attached.');
  $this
    ->assertTrue(isset($render['grants'][$gids[0]]['role']), 'The role property is attached.');
}