public function CowInstanceTest::testNodeRevisionCOW in Location 7.3
Same name and namespace in other branches
- 6.3 tests/cow.test \CowInstanceTest::testNodeRevisionCOW()
- 7.5 tests/cow.test \CowInstanceTest::testNodeRevisionCOW()
- 7.4 tests/cow.test \CowInstanceTest::testNodeRevisionCOW()
File
- tests/
cow.test, line 208
Class
- CowInstanceTest
- Class CowInstanceTest.
Code
public function testNodeRevisionCOW() {
$settings = array();
$location_type = $this
->addLocationContentType($settings, array(
'multiple' => array(
'max' => 3,
'add' => 3,
),
));
$location1_name = $this
->randomName();
$location2_name = $this
->randomName();
$location3_name = $this
->randomName();
$node = $this
->drupalCreateNode(array(
'type' => $location_type,
'locations' => array(
// First.
0 => array(
'name' => $location1_name,
'location_settings' => $settings,
),
// Second.
1 => array(
'name' => $location2_name,
'location_settings' => $settings,
),
),
));
// Reload the node.
$node = node_load($node->nid, NULL, TRUE);
$changes = array(
'revision' => TRUE,
'log' => $this
->randomName(20),
'locations' => array(
// Delete First.
0 => array(
'delete_location' => TRUE,
),
// Third.
2 => array(
'name' => $location3_name,
),
),
);
$this
->flattenPostData($changes);
$this
->drupalPost('node/' . $node->nid . '/edit', $changes, 'Save');
// Reload the node again.
$node1 = node_load($node->nid, $node->vid, TRUE);
$node2 = node_load($node->nid, NULL, TRUE);
// Ensure locations are in a consistent order.
$this
->reorderLocations($node);
$this
->reorderLocations($node1);
$this
->reorderLocations($node2);
$this
->assertEqual(count($node1->locations), 2, t('Ensuring second revision did not affect first revision'));
$this
->assertEqual($node->locations[0]['lid'], $node1->locations[0]['lid'], t('Ensuring second revision did not affect first revision'));
$this
->assertEqual($node->locations[1]['lid'], $node1->locations[1]['lid'], t('Ensuring second revision did not affect first revision'));
$this
->assertEqual(count($node2->locations), 2, t('Ensuring second revision does not have stealth locations'));
// Delete first revision.
db_query("DELETE FROM {node_revision} WHERE nid = :nid AND vid = :vid", array(
':nid' => $node1->nid,
':vid' => $node1->vid,
));
$this
->assertFalse(node_revision_delete($node1->vid));
}