You are here

function DomainInstallTest::testDomainEnable in Domain Access 7.3

File

tests/domain.test, line 181
Simpletest for Domain Access.

Class

DomainInstallTest

Code

function testDomainEnable() {

  // Delete records so we can test the installer.
  db_query("TRUNCATE {domain_access}");
  db_query("TRUNCATE {domain_editor}");

  // Check nodes.
  $nid = db_query_range("SELECT n.nid FROM {node} n INNER JOIN {domain_access} da ON n.nid = da.nid", 0, 1)
    ->fetchField();
  $this
    ->assertTrue(empty($nid), t('Initial nodes have no domain data.'));

  // Check users.
  $uid = db_query_range("SELECT u.uid FROM {users} u INNER JOIN {domain_editor} de ON u.uid = de.uid", 0, 1)
    ->fetchField();
  $this
    ->assertTrue(empty($uid), t('Initial users have no domain data.'));

  // Run domain_enable.
  domain_enable();

  // Check nodes.
  $nid = db_query_range("SELECT n.nid FROM {node} n INNER JOIN {domain_access} da ON n.nid = da.nid", 0, 1)
    ->fetchField();
  $this
    ->assertTrue(!empty($nid), t('Nodes have added domain data.'));

  // Check users.
  $uid = db_query_range("SELECT u.uid FROM {users} u INNER JOIN {domain_editor} de ON u.uid = de.uid", 0, 1)
    ->fetchField();
  $this
    ->assertTrue(!empty($uid), t('Users have added domain data.'));
}