You are here

function ContentCrudTestCase::_compareArrayForChanges in Content Construction Kit (CCK) 6.3

Same name and namespace in other branches
  1. 6 tests/content.crud.test \ContentCrudTestCase::_compareArrayForChanges()
  2. 6.2 tests/content.crud.test \ContentCrudTestCase::_compareArrayForChanges()

Helper function for assertNodeSaveValues. Recursively checks that all the keys of a table are present in a second and have the same value.

1 call to ContentCrudTestCase::_compareArrayForChanges()
ContentCrudTestCase::assertNodeValues in tests/content.crud.test
Checks that the output from node_load matches the expected values.

File

tests/content.crud.test, line 154

Class

ContentCrudTestCase
Base class for CCK CRUD tests. Defines many helper functions useful for writing CCK CRUD tests.

Code

function _compareArrayForChanges($fields, $data, $message, $prefix = '') {
  foreach ($fields as $key => $value) {
    $newprefix = $prefix == '' ? $key : $prefix . '][' . $key;
    if (is_array($value)) {
      $compare_to = isset($data[$key]) ? $data[$key] : array();
      $this
        ->_compareArrayForChanges($value, $compare_to, $message, $newprefix);
    }
    else {
      $this
        ->assertEqual($value, $data[$key], t($message, array(
        '!key' => $newprefix,
      )));
    }
  }
}