You are here

public function AuthcacheTestAdminWidgets::testRoleRestrictWidgetMembersOnly in Authenticated User Page Caching (Authcache) 7.2

Test members only role restrict widget.

File

tests/authcache.widget.test, line 328
Test cases for pluggable cache backends.

Class

AuthcacheTestAdminWidgets
Cover authcache module.

Code

public function testRoleRestrictWidgetMembersOnly() {
  $form = system_settings_form(array(
    'authcache_widget_test_roles' => array(
      '#title' => $this
        ->randomName(8),
      '#type' => 'authcache_role_restrict',
      '#default_value' => variable_get('authcache_widget_test_roles'),
      '#members_only' => TRUE,
    ),
  ));
  $form_stub = $this->stubmod
    ->hook('form', $form);
  $this
    ->drupalGet('authcache-widget-test-form');
  $this
    ->assertStub($form_stub, HookStub::once());
  $this
    ->assertNoText('Currently there are no roles enabled for authcache');
  $this
    ->assertNoLink('authcache settings');
  $this
    ->assertNoFieldChecked('edit-authcache-widget-test-roles-custom');
  $roles = user_roles();
  $expected_roles = $this->authcacheRoles;
  unset($expected_roles[DRUPAL_ANONYMOUS_RID]);
  foreach ($roles as $rid => $name) {
    if (in_array($rid, $expected_roles)) {
      $this
        ->assertFieldChecked('edit-authcache-widget-test-roles-roles-' . $rid);
      $this
        ->assertText($name);
    }
    else {
      $this
        ->assertNoText($name);
    }
  }
}