You are here

function LocationCCKTest::testCOWConservation in Location 6.3

Same name and namespace in other branches
  1. 7.5 tests/location_cck.test \LocationCCKTest::testCOWConservation()
  2. 7.3 tests/location_cck.test \LocationCCKTest::testCOWConservation()
  3. 7.4 tests/location_cck.test \LocationCCKTest::testCOWConservation()

File

tests/location_cck.test, line 396

Class

LocationCCKTest

Code

function testCOWConservation() {
  $settings = array();
  $location_type = $this
    ->addLocationContentType($settings);
  $location1_name = $this
    ->randomName();
  $node = $this
    ->drupalCreateNode(array(
    'type' => $location_type,
    'field_loctest' => array(
      0 => array(
        'name' => $location1_name,
        'location_settings' => $settings,
      ),
    ),
  ));

  // Reload the node.
  $node = node_load($node->nid, NULL, TRUE);
  $changes = array(
    'field_loctest' => array(
      0 => array(
        // Update name.
        'name' => $location1_name . '_CHANGE',
      ),
    ),
  );
  $this
    ->flattenPostData($changes);
  $this
    ->drupalPost('node/' . $node->nid . '/edit', $changes, 'Save');

  // Reload the node again.
  $node1 = node_load($node->nid, NULL, TRUE);

  // Ensure locations are in a consistent order.
  $this
    ->reorderLocations($node, 'field_loctest');
  $this
    ->reorderLocations($node1, 'field_loctest');
  $this
    ->assertEqual($node->field_loctest[0]['lid'], $node1->field_loctest[0]['lid'], t('Ensuring LIDs are conserved'));
}