You are here

function CoderUpgradeUnitTestCase::compareFiles in Coder 7.2

Same name and namespace in other branches
  1. 7 coder_upgrade/coder_upgrade.test \CoderUpgradeUnitTestCase::compareFiles()
1 call to CoderUpgradeUnitTestCase::compareFiles()
CoderUpgradeUnitTestCase::testRunInterface in coder_upgrade/coder_upgrade.test
Tests the upgrade routines (outside of the user interface).

File

coder_upgrade/coder_upgrade.test, line 183

Class

CoderUpgradeUnitTestCase
Unit tests for the upgrade routines.

Code

function compareFiles($expected_filename, $out_filename) {
  $name = pathinfo($out_filename, PATHINFO_BASENAME);
  $b1 = file_exists($expected_filename);
  $this
    ->assertTrue($b1, 'Expected file exists', $name);
  $b2 = file_exists($out_filename);
  $this
    ->assertTrue($b2, 'Output file exists', $name);

  // Save a copy outside of the simpletest directory that will be deleted.
  // TODO This copy may have name clashes.
  copy($out_filename, $this->site_directory . $name);
  if ($b1 && $b2) {
    $expected = file_get_contents($expected_filename);
    $actual = file_get_contents($out_filename);
    $this
      ->assertEqual($expected, $actual, 'Contents of output file match that of expected file', $name);
  }
  else {
    $this
      ->assertEqual('expected', 'actual', 'Contents of output file match that of expected file', $name);
  }
}