44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Tests\TestCase;
|
|
|
|
class UploadDatabaseBackupCommandTest extends TestCase
|
|
{
|
|
public function test_it_uploads_and_verifies_a_private_backup(): void
|
|
{
|
|
Storage::fake('backup-test');
|
|
config()->set('backup.database.disk', 'backup-test');
|
|
|
|
$source = tempnam(sys_get_temp_dir(), 'moonwell-backup-');
|
|
file_put_contents($source, 'compressed database dump');
|
|
|
|
try {
|
|
$this->artisan('backup:upload', [
|
|
'source' => $source,
|
|
'destination' => 'backups/databases/test.sql.gz',
|
|
])->assertSuccessful();
|
|
|
|
Storage::disk('backup-test')->assertExists('backups/databases/test.sql.gz');
|
|
$this->assertSame(
|
|
file_get_contents($source),
|
|
Storage::disk('backup-test')->get('backups/databases/test.sql.gz'),
|
|
);
|
|
} finally {
|
|
@unlink($source);
|
|
}
|
|
}
|
|
|
|
public function test_it_rejects_a_missing_source_file(): void
|
|
{
|
|
config()->set('backup.database.disk', 'backup-test');
|
|
|
|
$this->artisan('backup:upload', [
|
|
'source' => '/missing/database.sql.gz',
|
|
'destination' => 'backups/databases/test.sql.gz',
|
|
])->assertFailed();
|
|
}
|
|
}
|