function CowInstanceTest::testSharedLocation in Location 6.3
Same name and namespace in other branches
- 7.5 tests/cow.test \CowInstanceTest::testSharedLocation()
- 7.3 tests/cow.test \CowInstanceTest::testSharedLocation()
- 7.4 tests/cow.test \CowInstanceTest::testSharedLocation()
File
- tests/
cow.test, line 125
Class
Code
function testSharedLocation() {
$settings = array();
$location_type = $this
->addLocationContentType($settings);
$location1_name = $this
->randomName();
$node = $this
->drupalCreateNode(array(
'type' => $location_type,
'locations' => array(
0 => array(
'name' => $location1_name,
'location_settings' => $settings,
),
),
));
// Reload the node.
$node = node_load($node->nid, NULL, TRUE);
// Get the full location
$location = $node->locations[0];
$node2 = $this
->drupalCreateNode(array(
'type' => $location_type,
'locations' => array(
'0' => $location,
),
));
// Reload second node.
$node2 = node_load($node2->nid, NULL, TRUE);
$this
->assertNotEqual($node->nid, $node2->nid, t('Ensuring nodes are seperate'));
$this
->assertEqual($node->locations[0]['lid'], $node2->locations[0]['lid'], t('Testing shared location'));
$this
->deleteNode($node->nid);
// Force another reload.
$node2 = node_load($node2->nid, NULL, TRUE);
$this
->assertEqual($node2->locations[0]['lid'], $location['lid'], t('Ensuring shared location is not prematurely garbage collected'));
$this
->deleteNode($node2->nid);
$result = db_query('SELECT * FROM {location} WHERE lid = %d', $location['lid']);
if ($row = db_fetch_object($result)) {
$this
->fail(t('Ensuring shared location is garbage collected'));
}
else {
$this
->pass(t('Ensuring shared location is garbage collected'));
}
}