Skip to content

Laravel 8 #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
composer.lock
.DS_Store
.phpunit.result.cache
*.old
15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ script:

jobs:
include:
- php: 7.1
env:
- ILLUMINATE_VERSION=5.8.*
- php: 7.2.24
env:
- ILLUMINATE_VERSION=5.8.*
- php: 7.2.24
env:
- ILLUMINATE_VERSION=6.0.*
- php: 7.2.24
env:
- ILLUMINATE_VERSION=7.0.*
Expand All @@ -37,3 +28,9 @@ jobs:
- php: 7.4
env:
- ILLUMINATE_VERSION=^7.0
- php: 7.3
env:
- ILLUMINATE_VERSION=^8.0
- php: 7.4
env:
- ILLUMINATE_VERSION=^8.0
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ Backup Shield simply listens for when the .zip-file generated by Laravel-backup
composer require olssonm/laravel-backup-shield
```

Supports `laravel/framework: "^5.8"` and above (including Laravel 6 & 7.) Requires `PHP: "^7.1"`.

Please note that `spatie/laravel-backup: "^6"` and `laravel/framework: "^6.0|^7.0"` requires PHP 7.2.

## Configuration
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
}
],
"require": {
"php": ">=7.1",
"illuminate/support": "~5.8|^6.0|^7.0",
"php": "^7.2",
"illuminate/support": "^6.0|^7.0|^8.0",
"nelexa/zip": "3.3",
"spatie/laravel-backup": "~5.0|~6.0"
"spatie/laravel-backup": "~6.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5|^8.0",
"orchestra/testbench": "^3.8|^4|^5"
"phpunit/phpunit": "^8.0|^9.0",
"orchestra/testbench": "^4.0|^5.0|^6.0"
},
"autoload": {
"psr-4": {
Expand Down
21 changes: 11 additions & 10 deletions src/BackupShieldServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,19 @@
namespace Olssonm\BackupShield;

use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;

use Olssonm\BackupShield\Factories\Password;
use Olssonm\BackupShield\Encryption;

use Spatie\Backup\Events\BackupZipWasCreated;
use Olssonm\BackupShield\Listeners\PasswordProtectZip;

/**
* Laravel service provider for the Backup Shield-package
*/
class BackupShieldServiceProvider extends ServiceProvider
{
/**
* Register listener to the "BackupZipWasCreated" event
* @var array
*/
protected $listen = [
'Spatie\Backup\Events\BackupZipWasCreated' => [
'Olssonm\BackupShield\Listeners\PasswordProtectZip',
],
];

/**
* Config-path
* @var string
Expand Down Expand Up @@ -50,6 +45,12 @@ public function boot() : void
$this->config => config_path('backup-shield.php'),
]);

// Listen for the "BackupZipWasCreated" event
Event::listen(
BackupZipWasCreated::class,
PasswordProtectZip::class
);

parent::boot();
}

Expand Down
5 changes: 3 additions & 2 deletions tests/BackupShieldTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function setUp(): void

/**
* Load the package
*
*
* @return array the packages
*/
protected function getPackageProviders($app)
Expand Down Expand Up @@ -59,13 +59,14 @@ public function testListenerReturnData()
$path = __DIR__ . '/resources/test.zip';
$pathTest = __DIR__ . '/resources/processed.zip';

// Make backup
// Make file ready for testing
copy($path, $pathTest);

// Manually set config
config()->set('backup-shield.password', 'M79Y6aKARXa9yLrcZd3srz');
config()->set('backup-shield.encryption', \Olssonm\BackupShield\Encryption::ENCRYPTION_WINZIP_AES_256);

// Fire event
$data = event(new BackupZipWasCreated($pathTest));

$this->assertEquals($pathTest, $data[0]);
Expand Down