Skip to content

Commit 8b388fa

Browse files
authored
Merge pull request #14 from olssonm/dev
Support for Laravel 7. Updated nelexa/zip-library.
2 parents 7e15124 + d4fe826 commit 8b388fa

File tree

8 files changed

+55
-22
lines changed

8 files changed

+55
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/vendor
22
composer.lock
33
.DS_Store
4+
.phpunit.result.cache

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,18 @@ matrix:
2020
- php: 7.2.24
2121
env:
2222
- ILLUMINATE_VERSION=6.0.*
23+
- php: 7.2.24
24+
env:
25+
- ILLUMINATE_VERSION=7.0.*
2326
- php: 7.2.24
2427
env:
2528
- ILLUMINATE_VERSION=^6.0
2629
- php: 7.3
2730
env:
2831
- ILLUMINATE_VERSION=^6.0
32+
- php: 7.3
33+
env:
34+
- ILLUMINATE_VERSION=^7.0
35+
- php: 7.4
36+
env:
37+
- ILLUMINATE_VERSION=^7.0

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
Copyright (c) 2019 Marcus Olsson <contact@marcusolsson.me>
3+
Copyright (c) 2020 Marcus Olsson <contact@marcusolsson.me>
44

55
> Permission is hereby granted, free of charge, to any person obtaining a copy
66
> of this software and associated documentation files (the "Software"), to deal

README.md

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

24-
Requires `PHP: "^7.1"` and `laravel/framework: "^5.8"`. Compatible with Laravel 6.
24+
Supports `laravel/framework: "^5.8"` and above (including Laravel 6 & 7.) Requires `PHP: "^7.1"`.
2525

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

2828
## Configuration
2929

@@ -41,7 +41,7 @@ return [
4141

4242
#### Password
4343

44-
Your password (*duh*). The default is the application key (`APP_KEY` in your .env-file). You might want to set something more appropriate. Remember to use long strings and to keep your password safe – without it you will never be able to open your backup.
44+
Your password (*duh*). The default is the application key (`APP_KEY` in your .env-file). You might want to set something more appropriate. Remember to use long strings and to keep your password safe – **without it you will never be able to open your backup**.
4545

4646
Set to `NULL` if you want to keep your backup without a password.
4747

@@ -82,7 +82,7 @@ $ phpunit
8282

8383
The MIT License (MIT). Please see the [LICENSE.md](LICENSE.md) for more information.
8484

85-
© 2019 [Marcus Olsson](https://marcusolsson.me).
85+
© 2020 [Marcus Olsson](https://marcusolsson.me).
8686

8787
[ico-version]: https://img.shields.io/packagist/v/olssonm/laravel-backup-shield.svg?style=flat-square
8888
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square

composer.json

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

src/Encryption.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ class Encryption
5555
* @var array
5656
*/
5757
private $zipFileOptions = [
58-
self::ENCRYPTION_DEFAULT => ZipFile::ENCRYPTION_METHOD_TRADITIONAL,
59-
self::ENCRYPTION_WINZIP_AES_128 => ZipFile::ENCRYPTION_METHOD_WINZIP_AES_128,
60-
self::ENCRYPTION_WINZIP_AES_192 => ZipFile::ENCRYPTION_METHOD_WINZIP_AES_192,
61-
self::ENCRYPTION_WINZIP_AES_256 => ZipFile::ENCRYPTION_METHOD_WINZIP_AES_256,
58+
self::ENCRYPTION_DEFAULT => \PhpZip\Constants\ZipEncryptionMethod::PKWARE,
59+
self::ENCRYPTION_WINZIP_AES_128 => \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_128,
60+
self::ENCRYPTION_WINZIP_AES_192 => \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_192,
61+
self::ENCRYPTION_WINZIP_AES_256 => \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256,
6262
];
6363

6464
/**

src/config/backup-shield.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'encryption' => \Olssonm\BackupShield\Encryption::ENCRYPTION_DEFAULT
66

77
// Available encryption methods:
8-
// \Olssonm\BackupShield\Encryption::ENCRYPTION_DEFAULT (PHP < 7.2: PKWARE/ZipCrypto, PHP >= 7.2 AES 128)
8+
// \Olssonm\BackupShield\Encryption::ENCRYPTION_DEFAULT (PHP < 7.2: PKWARE/ZipCrypto, PHP >= 7.2: AES 128)
99
// \Olssonm\BackupShield\Encryption::ENCRYPTION_WINZIP_AES_128 (AES 128)
1010
// \Olssonm\BackupShield\Encryption::ENCRYPTION_WINZIP_AES_192 (AES 192)
1111
// \Olssonm\BackupShield\Encryption::ENCRYPTION_WINZIP_AES_256 (AES 256)

tests/BackupShieldTests.php

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,57 @@ public function test_listener_return_data()
6868
$this->assertEquals($pathTest, $data[0]);
6969
}
7070

71+
/** @test **/
72+
public function test_correct_encrypter_engine()
73+
{
74+
$path = __DIR__ . '/resources/processed.zip';
75+
76+
// Use Zip-file to check attributes of the file
77+
$zipFile = (new ZipFile())->openFile($path);
78+
$zipInfo = $zipFile->getAllInfo();
79+
80+
// Assume PHP 7.2 and supporter ZipArchive
81+
if (class_exists('ZipArchive') && in_array('setEncryptionIndex', get_class_methods('ZipArchive'))) {
82+
$this->assertEquals(9, $zipInfo['backup.zip']->getCompressionLevel()); // 9 = ZipArchive
83+
}
84+
// Fallback on ZipFile
85+
else {
86+
$this->assertEquals(5, $zipInfo['backup.zip']->getCompressionLevel()); // 5 = ZipFile
87+
}
88+
}
89+
7190
/** @test **/
7291
public function test_encryption_protection()
7392
{
7493
// Test that the archive actually is encrypted and password protected
7594
$path = __DIR__ . '/resources/processed.zip';
7695

96+
// Use Zip-file to check attributes of the file
7797
$zipFile = (new ZipFile())->openFile($path);
7898
$zipInfo = $zipFile->getAllInfo();
7999

80100
$this->assertEquals(true, $zipInfo['backup.zip']->isEncrypted());
81101
$this->assertEquals('backup.zip', $zipInfo['backup.zip']->getName());
82-
$this->assertEquals(0, $zipInfo['backup.zip']->getEncryptionMethod());
102+
$this->assertEquals(1, $zipInfo['backup.zip']->getEncryptionMethod());
83103
}
84104

85105
/** Teardown */
86106
public static function tearDownAfterClass(): void
87107
{
88108
// Delete config and test-files
89-
unlink(__DIR__ . '/resources/processed.zip');
109+
$processedFile = __DIR__ . '/resources/processed.zip';
110+
if (file_exists($processedFile)) {
111+
unlink($processedFile);
112+
}
90113

91-
$configTestPath = __DIR__ . '/../vendor/orchestra/testbench-core/laravel/config/backup-shield.php';
92-
if (file_exists($configTestPath)) {
93-
unlink(__DIR__ . '/../vendor/orchestra/testbench-core/laravel/config/backup-shield.php');
114+
$configTestFile = __DIR__ . '/../vendor/orchestra/testbench-core/laravel/config/backup-shield.php';
115+
if (file_exists($configTestFile)) {
116+
unlink($configTestFile);
94117
}
95118

96-
$configTestPathAlt = __DIR__ . '/../vendor/orchestra/testbench-core/fixture/config/backup-shield.php';
97-
if (file_exists($configTestPathAlt)) {
98-
unlink(__DIR__ . '/../vendor/orchestra/testbench-core/fixture/config/backup-shield.php');
119+
$configTestFileAlt = __DIR__ . '/../vendor/orchestra/testbench-core/fixture/config/backup-shield.php';
120+
if (file_exists($configTestFileAlt)) {
121+
unlink($configTestFileAlt);
99122
}
100123

101124
parent::tearDownAfterClass();

0 commit comments

Comments
 (0)