You are here

function BlockAccessRegionSpecificTestCase::testCannotAccessRegion in Block Access 7

Test we can block $user1 access to a region

File

tests/op_region.test, line 53
Tests for block_access / region-specific operations ('cannot access region header etc)

Class

BlockAccessRegionSpecificTestCase
Tests for block_access / region-specific operations ('cannot access region header etc)

Code

function testCannotAccessRegion() {

  // Block access only to $user1 role
  $this
    ->blockAccessToRegion($this->role1, 'sidebar_second', TRUE);
  $this
    ->blockAccessToRegion($this->role2, 'sidebar_second', FALSE);

  // Verify $user1 cannot access region
  $this
    ->drupalLogin($this->user1);
  $this
    ->drupalGet('admin/structure/block');
  $this
    ->assertResponse(200);
  $this
    ->assertNoOption('blocks[block_' . $this->block->delta . '][region]', 'sidebar_second');

  // Verify $user2 can access region
  $this
    ->drupalLogin($this->user2);
  $this
    ->drupalGet('admin/structure/block');
  $this
    ->assertResponse(200);
  $this
    ->assertOption('blocks[block_' . $this->block->delta . '][region]', 'sidebar_second');
}