Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jan 12, 2022
1 parent 3e8bdfe commit 06991d7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 26 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"spatie/laravel-signal-aware-command": "^1.2",
"spatie/temporary-directory": "^2.0",
"symfony/console": "^6.0",
"symfony/finder": "^6.0"
"symfony/finder": "^6.0",
"ext-pcntl": "*"

This comment has been minimized.

Copy link
@ovillafuerte94

ovillafuerte94 Feb 9, 2022

According to the documentation, this library is not compatible with Windows

This comment has been minimized.

Copy link
@erikn69

erikn69 Feb 10, 2022

Contributor

@freekmurze I did make "ext-pcntl": "*" optional with SignalRegistry::isSupported() #1352

if ($this->runningInConsole() && SignalRegistry::isSupported()) {
$this->handlesSignals[] = SIGINT;
}

also on symfony/console 6.0 is optional
https://github.com/symfony/console/blob/aebf06c512f010da304767292e593998cd97667a/composer.json#L18-L23

},
"require-dev": {
"composer-runtime-api": "^2.0",
Expand Down
8 changes: 2 additions & 6 deletions src/BackupDestination/BackupDestination.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,15 @@ public function write(string $file): void

$handle = fopen($file, 'r+');

$hasWritten = $this->disk->getDriver()->writeStream(
$this->disk->getDriver()->writeStream(
$destination,
$handle,
$this->getDiskOptions()
$this->getDiskOptions(),
);

if (is_resource($handle)) {
fclose($handle);
}

if (! $hasWritten) {
throw InvalidBackupFile::writeError($this->backupName());
}
}

public function backupName(): string
Expand Down
17 changes: 0 additions & 17 deletions tests/BackupDestination/BackupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,6 @@ public function when_its_unable_to_read_the_stream_throws_exception()
$backup->stream();
}

/** @test */
public function when_its_unable_to_write_to_stream_throws_exception()
{
$mock = $this->partialMock(Local::class, function (MockInterface $mock) {
$mock->shouldReceive('writeStream')->once()->andReturn(false);
});
$adapter = new FilesystemAdapter(new Filesystem($mock));

$path = Storage::disk($diskName = 'local')->path(
$this->createFileOnDisk($diskName, $filePath = 'mysite.com/file.zip', now())
);
$backupDestination = new BackupDestination($adapter, $backupName = 'mysite', $diskName);

$this->expectException(InvalidBackupFile::class);
$backupDestination->write($path);
}

/** @test */
public function it_can_delete_itself()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Commands/BackupCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function it_includes_files_from_the_local_disks_in_the_backup()
/** @test */
public function it_excludes_the_backup_destination_from_the_backup()
{
config()->set('backup.backup.source.files.include', [$this->getDiskRootPath('local')]);
config()->set('backup.backup.source.files.include', [$this->getFullDiskPath('local','testing-file.txt')]);

Storage::disk('local')->put('mysite/testing-file.txt', 'dummy content');

Expand Down
3 changes: 2 additions & 1 deletion tests/Events/BackupWasSuccessfulTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Spatie\Backup\Tests\Events;

use Illuminate\Support\Facades\Event;
use Spatie\Backup\Commands\BackupCommand;
use Spatie\Backup\Events\BackupWasSuccessful;
use Spatie\Backup\Tests\TestCase;

Expand All @@ -13,7 +14,7 @@ public function it_will_fire_an_event_after_a_backup_was_completed_successfully(
{
Event::fake();

$this->artisan('backup:run', ['--only-files' => true]);
$this->artisan(BackupCommand::class, ['--only-files' => true]);

Event::assertDispatched(BackupWasSuccessful::class);
}
Expand Down

0 comments on commit 06991d7

Please sign in to comment.