You are here

public function DomainSourceTest::testDomainSourceSave in Domain Access 7.3

File

domain_source/tests/domain_source.test, line 36
Simpletest for Domain Source.

Class

DomainSourceTest
@file Simpletest for Domain Source.

Code

public function testDomainSourceSave() {

  // These nodes should all be assigned to the primary domain.
  $node = node_load(1);

  // $node->domain_source should be NULL.
  $this
    ->assertTrue(is_null($node->domain_source), t('Source domain for initial content returns NULL.'));

  // Save the node with an assigned source. Then load and check.
  $node->domain_source = domain_default_id();
  node_save($node);

  // Check that a source record appears.
  $records = db_query("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {domain_source} ds ON n.nid = ds.nid")
    ->fetchField();
  $this
    ->assertTrue($records == 1, t('Saved node has domain source data.'));

  // Check that the data is loaded cleanly.
  $node = node_load(1);
  $this
    ->assertTrue($node->domain_source == domain_default_id(), t('Source domain for initial content loaded correctly.'));

  // Save the node with no assigned source. Then load and check.
  $node->domain_source = DOMAIN_SOURCE_USE_ACTIVE;
  node_save($node);

  // Check that the data is loaded cleanly.
  $node = node_load(1);
  $this
    ->assertTrue($node->domain_source == DOMAIN_SOURCE_USE_ACTIVE, t('Source domain for initial content loaded correctly as "use active domain".'));
}