You are here

function BackupMigrateUnitTest::testBZipEncode in Backup and Migrate 5

File

tests/BackupMigrateUnitTest.test, line 567

Class

BackupMigrateUnitTest
Unit tests for Backup and Migrate module.

Code

function testBZipEncode() {

  // zip a known file and compare it to a compressed zip
  $tempfile = file_directory_temp() . "/" . $this
    ->randomName(10, 'bztest');
  $knownfile = drupal_get_path('module', 'backup_migrate') . "/tests/test.txt";
  _backup_migrate_bzip_encode($knownfile, $tempfile);
  $temp_contents = file_get_contents($tempfile);
  $known_contents = file_get_contents($knownfile);
  $this
    ->assertEqual(md5($temp_contents), md5(bzcompress($known_contents, 9)));
  $this
    ->assertEqual(bzdecompress($temp_contents), $known_contents);
  unlink($tempfile);
}