Skip to content

Commit 4c78044

Browse files
author
Wim
authored
Merge pull request #1 from gumbo-millennium/master
Improved Laravel 6 Support
2 parents b5b0414 + e6484b1 commit 4c78044

39 files changed

+193
-70
lines changed

.github/workflows/test.yml

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: "Run unit tests"
2+
3+
on:
4+
- push
5+
6+
jobs:
7+
test:
8+
name: "Build"
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
php: ['7.1', '7.2', '7.3', '7.4']
13+
laravel: ['5.5', '5.6', '5.7', '5.8', '6.x']
14+
exclude:
15+
# Laravel 6.x is 7.2+
16+
- php: '7.1'
17+
laravel: '6.x'
18+
services:
19+
database:
20+
image: mysql:5
21+
ports:
22+
- 13306:3306
23+
env:
24+
MYSQL_ROOT_PASSWORD: 'test'
25+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v1
29+
30+
- name: Setup PHP ${{ matrix.php }}
31+
uses: shivammathur/setup-php@master
32+
with:
33+
php-version: ${{ matrix.php }}
34+
extensions: json,mbstring,pdo,mysql,dom
35+
coverage: xdebug
36+
37+
- name: Start build on Code Climate
38+
continue-on-error: true
39+
run: |
40+
curl -o ./cc-test-reporter -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
41+
chmod +x ./cc-test-reporter
42+
./cc-test-reporter before-build
43+
44+
- name: Get user-level Composer cache
45+
id: composer-cache
46+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
47+
48+
- name: Setup Composer cache
49+
uses: actions/cache@v1
50+
with:
51+
path: ${{ steps.composer-cache.outputs.dir }}
52+
key: composer-${{ runner.os }}-${{ matrix.laravel }}-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
53+
restore-keys: |
54+
composer-${{ runner.os }}-${{ matrix.laravel }}-${{ matrix.php }}-
55+
composer-${{ runner.os }}-${{ matrix.laravel }}-
56+
composer-${{ runner.os }}-
57+
58+
59+
- name: Install dependencies for Laravel 5.5
60+
if: ( matrix.laravel == '5.5' )
61+
run: |
62+
composer require "phpunit/phpunit:^6.0" --no-update
63+
composer require "laravel/framework:~5.5.0" --no-update
64+
composer require "orchestra/database:~3.5.0" --no-update
65+
composer require "orchestra/testbench:~3.5.0" --no-update
66+
67+
- name: Install dependencies for Laravel 5.6
68+
if: ( matrix.laravel == '5.6' )
69+
run: |
70+
composer require "phpunit/phpunit:^7.0" --no-update
71+
composer require "laravel/framework:~5.6.0" --no-update
72+
composer require "orchestra/database:~3.6.0" --no-update
73+
composer require "orchestra/testbench:~3.6.0" --no-update
74+
75+
- name: Install dependencies for Laravel 5.7
76+
if: ( matrix.laravel == '5.7' )
77+
run: |
78+
composer require "phpunit/phpunit:^7.0" --no-update
79+
composer require "laravel/framework:~5.7.0" --no-update
80+
composer require "orchestra/database:~3.7.0" --no-update
81+
composer require "orchestra/testbench:~3.7.0" --no-update
82+
83+
- name: Install dependencies for Laravel 5.8
84+
if: ( matrix.laravel == '5.8' )
85+
run: |
86+
composer require "phpunit/phpunit:^7.0" --no-update
87+
composer require "laravel/framework:~5.8.0" --no-update
88+
composer require "orchestra/database:~3.8.0" --no-update
89+
composer require "orchestra/testbench:~3.8.0" --no-update
90+
91+
- name: Install dependencies for Laravel 6
92+
if: ( matrix.laravel == '6.x' )
93+
run: |
94+
composer require "phpunit/phpunit:^8.3" --no-update
95+
composer require "laravel/framework:^6.0" --no-update
96+
composer require "orchestra/database:^4.0" --no-update
97+
composer require "orchestra/testbench:^4.0" --no-update
98+
99+
- name: Install composer dependencies
100+
run: composer install --no-suggest --no-progress --no-interaction --prefer-source
101+
102+
- name: Run unit tests
103+
run: vendor/bin/phpunit --coverage-text
104+
env:
105+
TESTING_DB_PASS: 'test'
106+
TESTING_DB_PORT: 13306
107+
108+
- name: Complete build on Code Climate
109+
continue-on-error: true
110+
run: ./cc-test-reporter after-build --coverage-input-type clover --prefix "${GITHUB_WORKSPACE}" --exit-code ${{ job.status == 'failure' }}
111+
if: always()
112+
113+
- name: Upload coverage to Code Climate
114+
continue-on-error: true
115+
run: vendor/bin/test-reporter

.travis.yml

+11-20
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ matrix:
1919
- php: 7.2
2020
env: LARAVEL=58
2121
- php: 7.2
22-
env: LARAVEL=6
22+
env: LARAVEL=6x
2323
- php: 7.3
2424
env: LARAVEL=55
2525
- php: 7.3
@@ -29,27 +29,18 @@ matrix:
2929
- php: 7.3
3030
env: LARAVEL=58
3131
- php: 7.3
32-
env: LARAVEL=6
32+
env: LARAVEL=6x
3333

3434
services:
3535
- mysql
3636

3737
before_script:
38-
# Extensions: ext-uopz
39-
- if [ "$TRAVIS_PHP_VERSION" = "7.1" ] ; then pecl install uopz ; fi
40-
- if [ "$TRAVIS_PHP_VERSION" = "7.2" ] ; then pecl install uopz ; fi
41-
# - if [ "$TRAVIS_PHP_VERSION" = "7.3" ] ; then wget -O $TRAVIS_BUILD_DIR/uopz-5.0.2.tgz https://pecl.php.net/get/uopz-5.0.2.tgz ; fi
42-
# - if [ "$TRAVIS_PHP_VERSION" = "7.3" ] ; then tar xvf $TRAVIS_BUILD_DIR/uopz-5.0.2.tgz ; fi
43-
# - if [ "$TRAVIS_PHP_VERSION" = "7.3" ] ; then mv $TRAVIS_BUILD_DIR/uopz-5.0.2 $TRAVIS_BUILD_DIR/ext-uopz ; fi
44-
# - if [ "$TRAVIS_PHP_VERSION" = "7.3" ] ; then wget -O $TRAVIS_BUILD_DIR/ext-uopz/php73.patch https://gist.githubusercontent.com/cmb69/3060a552fc825497d066262ab31f3998/raw/428c0aee7d77b6c37ea3757bbc8b86cfc390d7ca/0001-Update-for-PHP-7.3.patch ; fi
45-
# - if [ "$TRAVIS_PHP_VERSION" = "7.3" ] ; then cd $TRAVIS_BUILD_DIR/ext-uopz && patch -p1 < php73.patch && phpize && ./configure && make && make install ; fi
4638
# Tests: Code Climate
4739
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
4840
- chmod +x ./cc-test-reporter
4941
- ./cc-test-reporter before-build
50-
# Packages: Install
42+
# Packages: Prepare composer
5143
- composer self-update
52-
- composer install --prefer-source --no-interaction
5344

5445
script:
5546
# Packages: Laravel 5.5.x
@@ -72,15 +63,15 @@ script:
7263
- if [ "$LARAVEL" = "58" ] ; then composer require "laravel/framework:5.8.*" --no-update ; fi
7364
- if [ "$LARAVEL" = "58" ] ; then composer require "orchestra/database:3.8.*" --no-update ; fi
7465
- if [ "$LARAVEL" = "58" ] ; then composer require "orchestra/testbench:3.8.*" --no-update ; fi
75-
# Packages: Laravel 6.x.x
76-
- if [ "$LARAVEL" = "6" ] ; then composer require "phpunit/phpunit:^8.0" --no-update ; fi
77-
- if [ "$LARAVEL" = "6" ] ; then composer require "laravel/framework:^6.0" --no-update ; fi
78-
- if [ "$LARAVEL" = "6" ] ; then composer require "orchestra/database:^4.0" --no-update ; fi
79-
- if [ "$LARAVEL" = "6" ] ; then composer require "orchestra/testbench:^4.0" --no-update ; fi
80-
# Packages: Update
81-
- composer update --prefer-source --no-interaction
66+
# Packages: Laravel ^6.0
67+
- if [ "$LARAVEL" = "6x" ] ; then composer require "phpunit/phpunit:^8.3" --no-update ; fi
68+
- if [ "$LARAVEL" = "6x" ] ; then composer require "laravel/framework:^6.0" --no-update ; fi
69+
- if [ "$LARAVEL" = "6x" ] ; then composer require "orchestra/database:^4.0" --no-update ; fi
70+
- if [ "$LARAVEL" = "6x" ] ; then composer require "orchestra/testbench:^4.0" --no-update ; fi
71+
# Packages: Install
72+
- composer install --prefer-source --no-interaction
8273
# Tests: Run
83-
- vendor/bin/phpunit --coverage-clover "$TRAVIS_BUILD_DIR/build/logs/clover.xml"
74+
- composer test -- --coverage-clover "$TRAVIS_BUILD_DIR/build/logs/clover.xml"
8475

8576
after_script:
8677
- ./cc-test-reporter after-build --coverage-input-type clover --prefix "$TRAVIS_BUILD_DIR" --exit-code $TRAVIS_TEST_RESULT

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Laravel|[v5.5](https://laravel.com/docs/5.5/releases)|[v0.1.0](https://github.co
7575
Laravel|[v5.6](https://laravel.com/docs/5.6/releases)|[v0.1.1](https://github.com/austinheap/laravel-database-encryption/releases/tag/v0.1.1) ([Packagist](https://packagist.org/packages/austinheap/laravel-database-encryption#v0.1.1))|Stable|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.1.1)](https://travis-ci.org/austinheap/laravel-database-encryption)|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.1.1)](https://travis-ci.org/austinheap/laravel-database-encryption)|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.1.1)](https://travis-ci.org/austinheap/laravel-database-encryption)
7676
Laravel|[v5.7](https://laravel.com/docs/5.7/releases)|[v0.2.0](https://github.com/austinheap/laravel-database-encryption/releases/tag/v0.2.0) ([Packagist](https://packagist.org/packages/austinheap/laravel-database-encryption#v0.2.0))|Stable|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.2.0)](https://travis-ci.org/austinheap/laravel-database-encryption)|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.2.0)](https://travis-ci.org/austinheap/laravel-database-encryption)|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.2.0)](https://travis-ci.org/austinheap/laravel-database-encryption)
7777
Laravel|[v5.8](https://laravel.com/docs/5.8/releases)|[v0.2.1](https://github.com/austinheap/laravel-database-encryption/releases/tag/v0.2.1) ([Packagist](https://packagist.org/packages/austinheap/laravel-database-encryption#v0.2.1))|Stable|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.2.1)](https://travis-ci.org/austinheap/laravel-database-encryption)|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.2.1)](https://travis-ci.org/austinheap/laravel-database-encryption)|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.2.1)](https://travis-ci.org/austinheap/laravel-database-encryption)
78-
Laravel|[v6.x](https://laravel.com/docs/6.x/releases)|[v0.2.2](https://github.com/austinheap/laravel-database-encryption/releases/tag/v0.2.2) ([Packagist](https://packagist.org/packages/austinheap/laravel-database-encryption#v0.2.2))|Stable|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.2.2)](https://travis-ci.org/austinheap/laravel-database-encryption)|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.2.2)](https://travis-ci.org/austinheap/laravel-database-encryption)|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.2.2)](https://travis-ci.org/austinheap/laravel-database-encryption)
78+
Laravel|[v6.x](https://laravel.com/docs/6.x/releases)|[v0.3.0](https://github.com/austinheap/laravel-database-encryption/releases/tag/v0.3.0) ([Packagist](https://packagist.org/packages/austinheap/laravel-database-encryption#v0.3.0))|Stable|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.3.0)](https://travis-ci.org/austinheap/laravel-database-encryption)|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.3.0)](https://travis-ci.org/austinheap/laravel-database-encryption)|[![Build Status](https://travis-ci.org/austinheap/laravel-database-encryption.svg?branch=v0.3.0)](https://travis-ci.org/austinheap/laravel-database-encryption)
7979

8080
## Schemas
8181

composer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
},
6060
"require-dev": {
6161
"codeclimate/php-test-reporter": "dev-master",
62-
"phpunit/phpunit": "~6.0|~7.0",
62+
"phpunit/phpunit": "^6.0|^7.0|^8.0",
6363
"orchestra/testbench": "^3.5|^4.0"
6464
},
6565
"autoload": {
@@ -83,5 +83,8 @@
8383
},
8484
"config": {
8585
"discard-changes": true
86+
},
87+
"scripts": {
88+
"test": "vendor/bin/phpunit"
8689
}
8790
}

phpunit.xml

+2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
convertErrorsToExceptions="true"
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
9+
convertDeprecationsToExceptions="false"
910
processIsolation="false"
11+
failOnWarning="false"
1012
stopOnFailure="false">
1113

1214
<filter>

src/Console/Commands/MigrateEncryptionCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* src/Console/Commands/MigrateEncryptionCommand.php.
44
*
55
* @author Austin Heap <[email protected]>
6-
* @version v0.2.2
6+
* @version v0.3.0
77
*/
88
declare(strict_types=1);
99

src/EncryptionDefaults.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* src/EncryptionDefaults.php.
44
*
55
* @author Austin Heap <[email protected]>
6-
* @version v0.2.2
6+
* @version v0.3.0
77
*/
88
declare(strict_types=1);
99

src/EncryptionFacade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* src/EncryptionFacade.php.
44
*
55
* @author Austin Heap <[email protected]>
6-
* @version v0.2.2
6+
* @version v0.3.0
77
*/
88
declare(strict_types=1);
99

src/EncryptionHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* src/EncryptionHelper.php.
44
*
55
* @author Austin Heap <[email protected]>
6-
* @version v0.2.2
6+
* @version v0.3.0
77
*/
88
declare(strict_types=1);
99

src/EncryptionServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* src/EncryptionServiceProvider.php.
44
*
55
* @author Austin Heap <[email protected]>
6-
* @version v0.2.2
6+
* @version v0.3.0
77
*/
88
declare(strict_types=1);
99

src/Traits/HasEncryptedAttributes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* src/Traits/HasEncryptedAttributes.php.
44
*
55
* @author Austin Heap <[email protected]>
6-
* @version v0.2.2
6+
* @version v0.3.0
77
*/
88
declare(strict_types=1);
99

src/helpers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* src/helpers.php.
44
*
55
* @author Austin Heap <[email protected]>
6-
* @version v0.2.2
6+
* @version v0.3.0
77
*/
88
declare(strict_types=1);
99

tests/Console/MigrateEncryptionTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
* @package laravel-database-encryption
66
* @link https://github.com/austinheap/laravel-database-encryption
77
* @author Austin Heap <[email protected]>
8-
* @version v0.2.2
8+
* @version v0.3.0
99
*/
1010

1111
namespace AustinHeap\Database\Encryption\Tests\Console;
1212

1313
use AustinHeap\Database\Encryption\Console\Commands\MigrateEncryptionCommand;
1414
use AustinHeap\Database\Encryption\Tests\DatabaseTestCase;
1515
use DatabaseEncryption;
16+
use Illuminate\Support\Str;
1617
use RuntimeException;
1718

1819
/**
@@ -33,7 +34,7 @@ public function testMissingOldKeys()
3334
{
3435
protected function setupKeys()
3536
{
36-
$this->new_key = str_random(32);
37+
$this->new_key = Str::random(32);
3738
$this->tables = ['test_models'];
3839
}
3940
};
@@ -64,7 +65,7 @@ public function testMissingTables()
6465
protected function setupKeys()
6566
{
6667
$this->old_keys = [app('config')->get('app.key')];
67-
$this->new_key = str_random(32);
68+
$this->new_key = Str::random(32);
6869
}
6970
};
7071

@@ -81,7 +82,7 @@ public function testExtended()
8182
protected function setupKeys()
8283
{
8384
$this->old_keys = [app('config')->get('app.key')];
84-
$this->new_key = str_random(32);
85+
$this->new_key = Str::random(32);
8586
$this->tables = ['test_models'];
8687
}
8788
};

tests/DatabaseTestCase.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
* @package laravel-database-encryption
66
* @link https://github.com/austinheap/laravel-database-encryption
77
* @author Austin Heap <[email protected]>
8-
* @version v0.2.2
8+
* @version v0.3.0
99
*/
1010

1111
namespace AustinHeap\Database\Encryption\Tests;
1212

1313
use AustinHeap\Database\Encryption\Tests\Models\DatabaseModel;
1414
use DB, RuntimeException;
15+
use Illuminate\Support\Str;
1516

1617
/**
1718
* DatabaseTestCase
@@ -31,7 +32,7 @@ public function tearDown(): void
3132
protected function getEnvironmentSetUp($app): void
3233
{
3334
if (is_null(self::$database)) {
34-
self::$database = 'laravel_database_encryption_testing_' . str_random(6);
35+
self::$database = 'laravel_database_encryption_testing_' . Str::random(6);
3536
}
3637

3738
$this->setUpDatabase();
@@ -92,10 +93,13 @@ protected function runStatement(string $statement, ?string $database = null): vo
9293
$id = uniqid();
9394
$file = __DIR__ . '/testing-'.$id.'.sql';
9495
file_put_contents($file, is_null($database) ? $statement : 'USE ' . $database . '; ' . $statement);
95-
$cmd = 'mysql -u' . env('TESTING_DB_USER', 'root') .
96-
(empty(env('TESTING_DB_PASS', '')) ? '' : ' -p' . env('TESTING_DB_PASS', '')) .
97-
' -h ' . env('TESTING_DB_HOST', '127.0.0.1') .
98-
' < ' . $file . ' 2>&1 | grep -v "Warning: Using a password"';
96+
$cmd = vsprintf('mysql -u%s %s -h %s -P %s < %s 2>&1 | grep -v "Warning: Using a password"', [
97+
env('TESTING_DB_USER', 'root'),
98+
empty(env('TESTING_DB_PASS', '')) ? '' : ' -p' . env('TESTING_DB_PASS', ''),
99+
env('TESTING_DB_HOST', '127.0.0.1'),
100+
env('TESTING_DB_PORT', 3306),
101+
$file
102+
]);
99103
exec($cmd);
100104
unlink($file);
101105
}

tests/Defaults/ControlCharactersTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @package laravel-database-encryption
66
* @link https://github.com/austinheap/laravel-database-encryption
77
* @author Austin Heap <[email protected]>
8-
* @version v0.2.2
8+
* @version v0.3.0
99
*/
1010

1111
namespace AustinHeap\Database\Encryption\Tests\Defaults;

tests/Defaults/EnabledTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @package laravel-database-encryption
66
* @link https://github.com/austinheap/laravel-database-encryption
77
* @author Austin Heap <[email protected]>
8-
* @version v0.2.2
8+
* @version v0.3.0
99
*/
1010

1111
namespace AustinHeap\Database\Encryption\Tests\Defaults;

tests/Defaults/HelpersTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @package laravel-database-encryption
66
* @link https://github.com/austinheap/laravel-database-encryption
77
* @author Austin Heap <[email protected]>
8-
* @version v0.2.2
8+
* @version v0.3.0
99
*/
1010

1111
namespace AustinHeap\Database\Encryption\Tests\Defaults;

0 commit comments

Comments
 (0)