This commit is contained in:
Bozhidar 2024-05-02 20:35:37 +03:00
parent 093ac611b7
commit 28a9f2392d
3 changed files with 14 additions and 5 deletions

View file

@ -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) {

View file

@ -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);

View file

@ -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);