You are here

private function NodeImportAPITestCase::compareData in Node import 6

Compare data read from file with data that should be read from file.

Parameters

$file_data: Array. Data that should be read.

$data: Array. Data that has been read.

Return value

Boolean.

6 calls to NodeImportAPITestCase::compareData()
NodeImportAPITestCase::testEmptyLastColumn in tests/node_import.test
Test reading from files with empty last column. See #532182.
NodeImportAPITestCase::testLineEndingsDOS in tests/node_import.test
Test reading from CSV files with DOS line endings (\r\n).
NodeImportAPITestCase::testLineEndingsMac in tests/node_import.test
Test reading from CSV files with MacIntosh line endings (\r).
NodeImportAPITestCase::testLineEndingsUnix in tests/node_import.test
Test reading from CSV files with Unix line endings (\n).
NodeImportAPITestCase::testMultipleLines in tests/node_import.test
Test reading from files with multiple lines in quoted field.

... See full list

File

tests/node_import.test, line 74

Class

NodeImportAPITestCase

Code

private function compareData($file_data, $data) {
  if (count($data) != count($file_data)) {
    return $this
      ->fail(t('Number of read rows matches.'));
  }
  foreach ($file_data as $i => $row_data) {
    if (count($file_data[$i]) != count($data[$i])) {
      return $this
        ->fail(t('Number of fields in row %i matches.', array(
        '%i' => $i,
      )));
    }
    foreach ($row_data as $j => $value) {
      if (strcmp($file_data[$i][$j], $data[$i][$j])) {
        return $this
          ->fail(t('Data of field %j in row %i matches.', array(
          '%i' => $i,
          '%j' => $j,
        )));
      }
    }
  }
  return TRUE;
}