You are here

public function AccessSchemeInterfaceTest::testSchemeDelete in Access Control Kit 7

Delete an access scheme via the user interface.

File

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

Class

AccessSchemeInterfaceTest
Tests the access scheme interface.

Code

public function testSchemeDelete() {

  // Create an access scheme.
  $scheme = $this
    ->createScheme();
  $scheme = access_scheme_load($scheme->sid, TRUE);
  $this
    ->assertTrue($scheme, 'Access scheme found in the database.');

  // Create an access grant in the scheme.
  $grant = $this
    ->createGrant($scheme);
  $grant = access_grant_load($grant->gid, TRUE);
  $this
    ->assertTrue($grant, 'Access grant found in the database.');

  // Check deleting from the overview page.
  $this
    ->drupalGet('admin/structure/access');
  $this
    ->clickLink(t('delete'));
  $this
    ->assertRaw(t('Are you sure you want to delete the access scheme %name?', array(
    '%name' => $scheme->name,
  )), '[confirm deletion] Asks for confirmation.');

  // Delete the scheme.
  $edit = array();
  $this
    ->drupalPost('admin/structure/access/' . $scheme->machine_name, $edit, t('Delete access scheme'));
  $this
    ->assertRaw(t('Are you sure you want to delete the access scheme %name?', array(
    '%name' => $scheme->name,
  )), '[confirm deletion] Asks for confirmation.');
  $this
    ->assertRaw(t('All access grants within the scheme will also be deleted. %scheme currently contains 1 access grant on your site. If you remove this scheme, the user may not be able to exercise the permissions assigned by that grant.', array(
    '%scheme' => $scheme->name,
  )), '[confirm deletion] Informs that all grants will be deleted.');
  $this
    ->assertText(t('This action cannot be undone.'), '[confirm deletion] Informs that deletion is permanent.');

  // Confirm deletion.
  $this
    ->drupalPost(NULL, NULL, t('Delete'));
  $this
    ->assertRaw(t('Deleted access scheme %name.', array(
    '%name' => $scheme->name,
  )), 'Access scheme deleted.');
  $this
    ->assertFalse(access_grant_load($grant->gid, TRUE), 'Access grant is not found in the database.');
  $this
    ->assertFalse(access_scheme_load($scheme->sid, TRUE), 'Access scheme is not found in the database.');
}