From 28a9f2392da8b10c81c58d1c6136a7ccc7b18ff7 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Thu, 2 May 2024 20:35:37 +0300 Subject: [PATCH] update --- .../CreateDailyFullHostingSubscriptionsBackup.php | 2 +- web/app/Helpers.php | 9 +++++++++ web/tests/Unit/HostingSubscriptionBackupTest.php | 8 ++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/web/app/Console/Commands/CreateDailyFullHostingSubscriptionsBackup.php b/web/app/Console/Commands/CreateDailyFullHostingSubscriptionsBackup.php index 0018bad..c515f6d 100644 --- a/web/app/Console/Commands/CreateDailyFullHostingSubscriptionsBackup.php +++ b/web/app/Console/Commands/CreateDailyFullHostingSubscriptionsBackup.php @@ -36,7 +36,7 @@ class CreateDailyFullHostingSubscriptionsBackup extends Command public function handle() { // Find Hosting Subscriptions - $findHostingSubscriptions = HostingSubscription::limit(1)->get(); + $findHostingSubscriptions = HostingSubscription::all(); if ($findHostingSubscriptions->count() > 0) { foreach ($findHostingSubscriptions as $hostingSubscription) { diff --git a/web/app/Helpers.php b/web/app/Helpers.php index b603c95..8274518 100644 --- a/web/app/Helpers.php +++ b/web/app/Helpers.php @@ -4,6 +4,15 @@ namespace App; class Helpers { + public static function extractZip($tarFile, $extractPath) + { + shell_exec('mkdir -p ' . $extractPath); + + $exec = shell_exec('unzip -o ' . $tarFile . ' -d ' . $extractPath); + + return $exec; + } + public static function extractTar($tarFile, $extractPath) { shell_exec('mkdir -p ' . $extractPath); diff --git a/web/tests/Unit/HostingSubscriptionBackupTest.php b/web/tests/Unit/HostingSubscriptionBackupTest.php index abe4afe..60f36bd 100644 --- a/web/tests/Unit/HostingSubscriptionBackupTest.php +++ b/web/tests/Unit/HostingSubscriptionBackupTest.php @@ -87,14 +87,14 @@ class HostingSubscriptionBackupTest extends ActionTestCase $getFilesize = filesize($findBackup->file_path); $this->assertGreaterThan(0, $getFilesize); - $this->assertSame(Helpers::checkPathSize($findBackup->path), $findBackup->size); + $this->assertSame($getFilesize, $findBackup->size); - Helpers::extractTar($findBackup->file_path, $findBackup->path . '/unit-test'); + Helpers::extractZip($findBackup->file_path, $findBackup->path . '/unit-test'); // -// dd($chs); $findDatabase = Database::where('id', $chs['databaseId'])->first(); - $extractedDatabase = $findBackup->path . '/unit-test/' . $findDatabase->database_name_prefix . $findDatabase->database_name . '.sql'; + $extractedDatabase = $findBackup->path . '/unit-test/databases/' . $findDatabase->database_name_prefix . $findDatabase->database_name . '.sql'; + $this->assertTrue(file_exists($extractedDatabase)); $extractedDatabaseContent = file_get_contents($extractedDatabase); $this->assertNotEmpty($extractedDatabaseContent);