Skip to content

Commit 8e71542

Browse files
authored
Laravel 8 (#16)
* Set listener in boot-method * Update for Laravel 8 * Fix Travis YAML-syntax * Remove old dependencies * Add back phpunit 8 for php 7.2
1 parent a534ff1 commit 8e71542

File tree

6 files changed

+26
-28
lines changed

6 files changed

+26
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
composer.lock
33
.DS_Store
44
.phpunit.result.cache
5+
*.old

.travis.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ script:
1313

1414
jobs:
1515
include:
16-
- php: 7.1
17-
env:
18-
- ILLUMINATE_VERSION=5.8.*
19-
- php: 7.2.24
20-
env:
21-
- ILLUMINATE_VERSION=5.8.*
22-
- php: 7.2.24
23-
env:
24-
- ILLUMINATE_VERSION=6.0.*
2516
- php: 7.2.24
2617
env:
2718
- ILLUMINATE_VERSION=7.0.*
@@ -37,3 +28,9 @@ jobs:
3728
- php: 7.4
3829
env:
3930
- ILLUMINATE_VERSION=^7.0
31+
- php: 7.3
32+
env:
33+
- ILLUMINATE_VERSION=^8.0
34+
- php: 7.4
35+
env:
36+
- ILLUMINATE_VERSION=^8.0

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ Backup Shield simply listens for when the .zip-file generated by Laravel-backup
2121
composer require olssonm/laravel-backup-shield
2222
```
2323

24-
Supports `laravel/framework: "^5.8"` and above (including Laravel 6 & 7.) Requires `PHP: "^7.1"`.
25-
2624
Please note that `spatie/laravel-backup: "^6"` and `laravel/framework: "^6.0|^7.0"` requires PHP 7.2.
2725

2826
## Configuration

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
}
1919
],
2020
"require": {
21-
"php": ">=7.1",
22-
"illuminate/support": "~5.8|^6.0|^7.0",
21+
"php": "^7.2",
22+
"illuminate/support": "^6.0|^7.0|^8.0",
2323
"nelexa/zip": "3.3",
24-
"spatie/laravel-backup": "~5.0|~6.0"
24+
"spatie/laravel-backup": "~6.0"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^7.5|^8.0",
28-
"orchestra/testbench": "^3.8|^4|^5"
27+
"phpunit/phpunit": "^8.0|^9.0",
28+
"orchestra/testbench": "^4.0|^5.0|^6.0"
2929
},
3030
"autoload": {
3131
"psr-4": {

src/BackupShieldServiceProvider.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,19 @@
33
namespace Olssonm\BackupShield;
44

55
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
6+
use Illuminate\Support\Facades\Event;
7+
68
use Olssonm\BackupShield\Factories\Password;
79
use Olssonm\BackupShield\Encryption;
810

11+
use Spatie\Backup\Events\BackupZipWasCreated;
12+
use Olssonm\BackupShield\Listeners\PasswordProtectZip;
13+
914
/**
1015
* Laravel service provider for the Backup Shield-package
1116
*/
1217
class BackupShieldServiceProvider extends ServiceProvider
1318
{
14-
/**
15-
* Register listener to the "BackupZipWasCreated" event
16-
* @var array
17-
*/
18-
protected $listen = [
19-
'Spatie\Backup\Events\BackupZipWasCreated' => [
20-
'Olssonm\BackupShield\Listeners\PasswordProtectZip',
21-
],
22-
];
23-
2419
/**
2520
* Config-path
2621
* @var string
@@ -50,6 +45,12 @@ public function boot() : void
5045
$this->config => config_path('backup-shield.php'),
5146
]);
5247

48+
// Listen for the "BackupZipWasCreated" event
49+
Event::listen(
50+
BackupZipWasCreated::class,
51+
PasswordProtectZip::class
52+
);
53+
5354
parent::boot();
5455
}
5556

tests/BackupShieldTests.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function setUp(): void
1616

1717
/**
1818
* Load the package
19-
*
19+
*
2020
* @return array the packages
2121
*/
2222
protected function getPackageProviders($app)
@@ -59,13 +59,14 @@ public function testListenerReturnData()
5959
$path = __DIR__ . '/resources/test.zip';
6060
$pathTest = __DIR__ . '/resources/processed.zip';
6161

62-
// Make backup
62+
// Make file ready for testing
6363
copy($path, $pathTest);
6464

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

69+
// Fire event
6970
$data = event(new BackupZipWasCreated($pathTest));
7071

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

0 commit comments

Comments
 (0)