You are here

function BackupMigrateUnitTest::testGZipEncode in Backup and Migrate 5

File

tests/BackupMigrateUnitTest.test, line 544

Class

BackupMigrateUnitTest
Unit tests for Backup and Migrate module.

Code

function testGZipEncode() {

  // zip a known file and compare it to a compressed zip
  $tempfile = file_directory_temp() . "/" . $this
    ->randomName(10, 'gztest') . '.gz';
  $knownfile = drupal_get_path('module', 'backup_migrate') . "/tests/test.txt";
  $knownzip = drupal_get_path('module', 'backup_migrate') . "/tests/test.gz";
  _backup_migrate_gzip_encode($knownfile, $tempfile);
  $temp_contents = file_get_contents($tempfile);
  $known_contents = file_get_contents($knownfile);
  $knownzip_contents = file_get_contents($knownzip);
  $zd = gzopen($tempfile, "r");
  $temp_decoded = gzread($zd, 1000);
  gzclose($zd);
  $this
    ->assertEqual(md5($temp_contents), md5($knownzip_contents));
  $this
    ->assertEqual($temp_decoded, $known_contents);

  //unlink($tempfile);
}