You are here

function BackupMigrateUnitTest::testZipEncode in Backup and Migrate 5

File

tests/BackupMigrateUnitTest.test, line 583

Class

BackupMigrateUnitTest
Unit tests for Backup and Migrate module.

Code

function testZipEncode() {

  // zip a known file and compare it to a known compressed zip
  $tempfile = file_directory_temp() . "/" . $this
    ->randomName(10, 'ziptest') . ".zip";
  $knownfile = drupal_get_path('module', 'backup_migrate') . "/tests/test.txt";
  _backup_migrate_zip_encode($knownfile, $tempfile, 'test.txt');
  $zip = zip_open($tempfile);
  $entry = zip_read($zip);
  zip_entry_open($zip, $entry);
  $temp_contents = zip_entry_read($entry);
  $known_contents = file_get_contents($knownfile);

  //$this->assertEqual(md5($temp_contents), md5(bzcompress($known_contents, 9)));
  $this
    ->assertEqual($temp_contents, $known_contents);
  unlink($tempfile);
}