From 6d76e0d19c7ce7e2807c70ec48d0bb8efc453798 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Thu, 25 Apr 2024 15:26:18 +0300 Subject: [PATCH] update --- web/app/Helpers.php | 8 ++++++++ web/tests/Unit/BackupTest.php | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/web/app/Helpers.php b/web/app/Helpers.php index c7b16c5..b603c95 100644 --- a/web/app/Helpers.php +++ b/web/app/Helpers.php @@ -4,6 +4,14 @@ namespace App; class Helpers { + public static function extractTar($tarFile, $extractPath) + { + shell_exec('mkdir -p ' . $extractPath); + + $exec = shell_exec('tar -xvf ' . $tarFile . ' -C ' . $extractPath); + + return $exec; + } public static function checkPathSize($path) { diff --git a/web/tests/Unit/BackupTest.php b/web/tests/Unit/BackupTest.php index 9a1c080..1c669f6 100644 --- a/web/tests/Unit/BackupTest.php +++ b/web/tests/Unit/BackupTest.php @@ -65,9 +65,16 @@ class BackupTest extends ActionTestCase $getFilesize = filesize($findBackup->filepath); $this->assertGreaterThan(0, $getFilesize); - $this->assertSame(Helpers::checkPathSize($findBackup->path), $findBackup->size); + Helpers::extractTar($findBackup->filepath, $findBackup->path . '/unit-test'); + + $this->assertTrue(is_dir($findBackup->path . '/unit-test')); + $this->assertTrue(is_dir($findBackup->path . '/unit-test/' . $hostingSubscription->system_username)); + $this->assertTrue(is_dir($findBackup->path . '/unit-test/' . $hostingSubscription->system_username . '/public_html')); + $this->assertTrue(is_dir($findBackup->path . '/unit-test/' . $hostingSubscription->system_username . '/public_html/cgi-bin')); + $this->assertTrue(is_file($findBackup->path . '/unit-test/' . $hostingSubscription->system_username . '/public_html/index.php')); + } }