You are here

function AclWebTestCase::testNodeAclCreateDelete in ACL 7

Includes acl_create_acl, acl_delete_acl, acl_get_id_by_name

File

tests/acl.test, line 38
Tests for the ACL module.

Class

AclWebTestCase
Test case for ACL module.

Code

function testNodeAclCreateDelete() {

  // Add a node.
  $node1 = $this
    ->drupalCreateNode(array(
    'type' => 'page',
    'promote' => 0,
  ));
  $this
    ->assertTrue(node_load($node1->nid), t('Page node created.'));
  acl_create_acl('test1', $node1->title);
  $acl_id = acl_get_id_by_name('test1', $node1->title);
  $this
    ->assertNotNull($acl_id, t('ACL ID was succesfully found.'), $group = 'ACL');
  $records = db_query('SELECT acl_id, name FROM {acl} WHERE acl_id = :acl_id', array(
    ':acl_id' => $acl_id,
  ))
    ->fetchAll();
  $this
    ->assertEqual(count($records), 1, t('ACL was succesfully created.'), $group = 'ACL');
  acl_delete_acl($records[0]->acl_id);
  $records = db_query('SELECT acl_id, name FROM {acl} WHERE acl_id = :acl_id', array(
    ':acl_id' => $records[0]->acl_id,
  ))
    ->fetchAll();
  $this
    ->pass(var_export($records, TRUE));
  $this
    ->assertEqual(count($records), 0, t('ACL was succesfully removed.'), $group = 'ACL');
}