You are here

function LocationTestCase::reorderLocations in Location 7.5

Same name and namespace in other branches
  1. 6.3 tests/location_testcase.php \LocationTestCase::reorderLocations()
  2. 7.3 tests/location_testcase.test \LocationTestCase::reorderLocations()
  3. 7.4 tests/location_testcase.php \LocationTestCase::reorderLocations()

Order locations in a node by LID for testing repeatability purposes.

4 calls to LocationTestCase::reorderLocations()
CowInstanceTest::testCOWConservation in tests/cow.test
CowInstanceTest::testNodeRevisionCOW in tests/cow.test
LocationCCKTest::testCOWConservation in tests/location_cck.test
LocationCCKTest::testNodeRevisionCOW in tests/location_cck.test

File

tests/location_testcase.php, line 122
Common functions for Location tests.

Class

LocationTestCase
@file Common functions for Location tests.

Code

function reorderLocations(&$node, $field = 'locations') {
  $locations = array();
  foreach ($node->{$field} as $location) {
    if ($location['lid']) {
      $locations[$location['lid']] = $location;
    }
  }
  ksort($locations);
  $node->{$field} = array();
  foreach ($locations as $location) {
    $node->{$field}[] = $location;
  }
}