Skip to content

Improved Laravel 6 Support #1

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
Dec 16, 2019
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
115 changes: 115 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: "Run unit tests"

on:
- push

jobs:
test:
name: "Build"
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1', '7.2', '7.3', '7.4']
laravel: ['5.5', '5.6', '5.7', '5.8', '6.x']
exclude:
# Laravel 6.x is 7.2+
- php: '7.1'
laravel: '6.x'
services:
database:
image: mysql:5
ports:
- 13306:3306
env:
MYSQL_ROOT_PASSWORD: 'test'
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout repository
uses: actions/checkout@v1

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php }}
extensions: json,mbstring,pdo,mysql,dom
coverage: xdebug

- name: Start build on Code Climate
continue-on-error: true
run: |
curl -o ./cc-test-reporter -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
chmod +x ./cc-test-reporter
./cc-test-reporter before-build

- name: Get user-level Composer cache
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Setup Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.laravel }}-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.laravel }}-${{ matrix.php }}-
composer-${{ runner.os }}-${{ matrix.laravel }}-
composer-${{ runner.os }}-


- name: Install dependencies for Laravel 5.5
if: ( matrix.laravel == '5.5' )
run: |
composer require "phpunit/phpunit:^6.0" --no-update
composer require "laravel/framework:~5.5.0" --no-update
composer require "orchestra/database:~3.5.0" --no-update
composer require "orchestra/testbench:~3.5.0" --no-update

- name: Install dependencies for Laravel 5.6
if: ( matrix.laravel == '5.6' )
run: |
composer require "phpunit/phpunit:^7.0" --no-update
composer require "laravel/framework:~5.6.0" --no-update
composer require "orchestra/database:~3.6.0" --no-update
composer require "orchestra/testbench:~3.6.0" --no-update

- name: Install dependencies for Laravel 5.7
if: ( matrix.laravel == '5.7' )
run: |
composer require "phpunit/phpunit:^7.0" --no-update
composer require "laravel/framework:~5.7.0" --no-update
composer require "orchestra/database:~3.7.0" --no-update
composer require "orchestra/testbench:~3.7.0" --no-update

- name: Install dependencies for Laravel 5.8
if: ( matrix.laravel == '5.8' )
run: |
composer require "phpunit/phpunit:^7.0" --no-update
composer require "laravel/framework:~5.8.0" --no-update
composer require "orchestra/database:~3.8.0" --no-update
composer require "orchestra/testbench:~3.8.0" --no-update

- name: Install dependencies for Laravel 6
if: ( matrix.laravel == '6.x' )
run: |
composer require "phpunit/phpunit:^8.3" --no-update
composer require "laravel/framework:^6.0" --no-update
composer require "orchestra/database:^4.0" --no-update
composer require "orchestra/testbench:^4.0" --no-update

- name: Install composer dependencies
run: composer install --no-suggest --no-progress --no-interaction --prefer-source

- name: Run unit tests
run: vendor/bin/phpunit --coverage-text
env:
TESTING_DB_PASS: 'test'
TESTING_DB_PORT: 13306

- name: Complete build on Code Climate
continue-on-error: true
run: ./cc-test-reporter after-build --coverage-input-type clover --prefix "${GITHUB_WORKSPACE}" --exit-code ${{ job.status == 'failure' }}
if: always()

- name: Upload coverage to Code Climate
continue-on-error: true
run: vendor/bin/test-reporter
31 changes: 11 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ matrix:
- php: 7.2
env: LARAVEL=58
- php: 7.2
env: LARAVEL=6
env: LARAVEL=6x
- php: 7.3
env: LARAVEL=55
- php: 7.3
Expand All @@ -29,27 +29,18 @@ matrix:
- php: 7.3
env: LARAVEL=58
- php: 7.3
env: LARAVEL=6
env: LARAVEL=6x

services:
- mysql

before_script:
# Extensions: ext-uopz
- if [ "$TRAVIS_PHP_VERSION" = "7.1" ] ; then pecl install uopz ; fi
- if [ "$TRAVIS_PHP_VERSION" = "7.2" ] ; then pecl install uopz ; fi
# - 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
# - if [ "$TRAVIS_PHP_VERSION" = "7.3" ] ; then tar xvf $TRAVIS_BUILD_DIR/uopz-5.0.2.tgz ; fi
# - if [ "$TRAVIS_PHP_VERSION" = "7.3" ] ; then mv $TRAVIS_BUILD_DIR/uopz-5.0.2 $TRAVIS_BUILD_DIR/ext-uopz ; fi
# - 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
# - if [ "$TRAVIS_PHP_VERSION" = "7.3" ] ; then cd $TRAVIS_BUILD_DIR/ext-uopz && patch -p1 < php73.patch && phpize && ./configure && make && make install ; fi
# Tests: Code Climate
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
# Packages: Install
# Packages: Prepare composer
- composer self-update
- composer install --prefer-source --no-interaction

script:
# Packages: Laravel 5.5.x
Expand All @@ -72,15 +63,15 @@ script:
- if [ "$LARAVEL" = "58" ] ; then composer require "laravel/framework:5.8.*" --no-update ; fi
- if [ "$LARAVEL" = "58" ] ; then composer require "orchestra/database:3.8.*" --no-update ; fi
- if [ "$LARAVEL" = "58" ] ; then composer require "orchestra/testbench:3.8.*" --no-update ; fi
# Packages: Laravel 6.x.x
- if [ "$LARAVEL" = "6" ] ; then composer require "phpunit/phpunit:^8.0" --no-update ; fi
- if [ "$LARAVEL" = "6" ] ; then composer require "laravel/framework:^6.0" --no-update ; fi
- if [ "$LARAVEL" = "6" ] ; then composer require "orchestra/database:^4.0" --no-update ; fi
- if [ "$LARAVEL" = "6" ] ; then composer require "orchestra/testbench:^4.0" --no-update ; fi
# Packages: Update
- composer update --prefer-source --no-interaction
# Packages: Laravel ^6.0
- if [ "$LARAVEL" = "6x" ] ; then composer require "phpunit/phpunit:^8.3" --no-update ; fi
- if [ "$LARAVEL" = "6x" ] ; then composer require "laravel/framework:^6.0" --no-update ; fi
- if [ "$LARAVEL" = "6x" ] ; then composer require "orchestra/database:^4.0" --no-update ; fi
- if [ "$LARAVEL" = "6x" ] ; then composer require "orchestra/testbench:^4.0" --no-update ; fi
# Packages: Install
- composer install --prefer-source --no-interaction
# Tests: Run
- vendor/bin/phpunit --coverage-clover "$TRAVIS_BUILD_DIR/build/logs/clover.xml"
- composer test -- --coverage-clover "$TRAVIS_BUILD_DIR/build/logs/clover.xml"

after_script:
- ./cc-test-reporter after-build --coverage-input-type clover --prefix "$TRAVIS_BUILD_DIR" --exit-code $TRAVIS_TEST_RESULT
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Laravel|[v5.5](https://laravel.com/docs/5.5/releases)|[v0.1.0](https://github.co
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)
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)
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)
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)
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)

## Schemas

Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"require-dev": {
"codeclimate/php-test-reporter": "dev-master",
"phpunit/phpunit": "~6.0|~7.0",
"phpunit/phpunit": "^6.0|^7.0|^8.0",
"orchestra/testbench": "^3.5|^4.0"
},
"autoload": {
Expand All @@ -83,5 +83,8 @@
},
"config": {
"discard-changes": true
},
"scripts": {
"test": "vendor/bin/phpunit"
}
}
2 changes: 2 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
convertDeprecationsToExceptions="false"
processIsolation="false"
failOnWarning="false"
stopOnFailure="false">

<filter>
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/MigrateEncryptionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* src/Console/Commands/MigrateEncryptionCommand.php.
*
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/
declare(strict_types=1);

Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* src/EncryptionDefaults.php.
*
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/
declare(strict_types=1);

Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* src/EncryptionFacade.php.
*
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/
declare(strict_types=1);

Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* src/EncryptionHelper.php.
*
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/
declare(strict_types=1);

Expand Down
2 changes: 1 addition & 1 deletion src/EncryptionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* src/EncryptionServiceProvider.php.
*
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/
declare(strict_types=1);

Expand Down
2 changes: 1 addition & 1 deletion src/Traits/HasEncryptedAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* src/Traits/HasEncryptedAttributes.php.
*
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/
declare(strict_types=1);

Expand Down
2 changes: 1 addition & 1 deletion src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* src/helpers.php.
*
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/
declare(strict_types=1);

Expand Down
9 changes: 5 additions & 4 deletions tests/Console/MigrateEncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
* @package laravel-database-encryption
* @link https://github.com/austinheap/laravel-database-encryption
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/

namespace AustinHeap\Database\Encryption\Tests\Console;

use AustinHeap\Database\Encryption\Console\Commands\MigrateEncryptionCommand;
use AustinHeap\Database\Encryption\Tests\DatabaseTestCase;
use DatabaseEncryption;
use Illuminate\Support\Str;
use RuntimeException;

/**
Expand All @@ -33,7 +34,7 @@ public function testMissingOldKeys()
{
protected function setupKeys()
{
$this->new_key = str_random(32);
$this->new_key = Str::random(32);
$this->tables = ['test_models'];
}
};
Expand Down Expand Up @@ -64,7 +65,7 @@ public function testMissingTables()
protected function setupKeys()
{
$this->old_keys = [app('config')->get('app.key')];
$this->new_key = str_random(32);
$this->new_key = Str::random(32);
}
};

Expand All @@ -81,7 +82,7 @@ public function testExtended()
protected function setupKeys()
{
$this->old_keys = [app('config')->get('app.key')];
$this->new_key = str_random(32);
$this->new_key = Str::random(32);
$this->tables = ['test_models'];
}
};
Expand Down
16 changes: 10 additions & 6 deletions tests/DatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
* @package laravel-database-encryption
* @link https://github.com/austinheap/laravel-database-encryption
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/

namespace AustinHeap\Database\Encryption\Tests;

use AustinHeap\Database\Encryption\Tests\Models\DatabaseModel;
use DB, RuntimeException;
use Illuminate\Support\Str;

/**
* DatabaseTestCase
Expand All @@ -31,7 +32,7 @@ public function tearDown(): void
protected function getEnvironmentSetUp($app): void
{
if (is_null(self::$database)) {
self::$database = 'laravel_database_encryption_testing_' . str_random(6);
self::$database = 'laravel_database_encryption_testing_' . Str::random(6);
}

$this->setUpDatabase();
Expand Down Expand Up @@ -92,10 +93,13 @@ protected function runStatement(string $statement, ?string $database = null): vo
$id = uniqid();
$file = __DIR__ . '/testing-'.$id.'.sql';
file_put_contents($file, is_null($database) ? $statement : 'USE ' . $database . '; ' . $statement);
$cmd = 'mysql -u' . env('TESTING_DB_USER', 'root') .
(empty(env('TESTING_DB_PASS', '')) ? '' : ' -p' . env('TESTING_DB_PASS', '')) .
' -h ' . env('TESTING_DB_HOST', '127.0.0.1') .
' < ' . $file . ' 2>&1 | grep -v "Warning: Using a password"';
$cmd = vsprintf('mysql -u%s %s -h %s -P %s < %s 2>&1 | grep -v "Warning: Using a password"', [
env('TESTING_DB_USER', 'root'),
empty(env('TESTING_DB_PASS', '')) ? '' : ' -p' . env('TESTING_DB_PASS', ''),
env('TESTING_DB_HOST', '127.0.0.1'),
env('TESTING_DB_PORT', 3306),
$file
]);
exec($cmd);
unlink($file);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Defaults/ControlCharactersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package laravel-database-encryption
* @link https://github.com/austinheap/laravel-database-encryption
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/

namespace AustinHeap\Database\Encryption\Tests\Defaults;
Expand Down
2 changes: 1 addition & 1 deletion tests/Defaults/EnabledTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package laravel-database-encryption
* @link https://github.com/austinheap/laravel-database-encryption
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/

namespace AustinHeap\Database\Encryption\Tests\Defaults;
Expand Down
2 changes: 1 addition & 1 deletion tests/Defaults/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package laravel-database-encryption
* @link https://github.com/austinheap/laravel-database-encryption
* @author Austin Heap <[email protected]>
* @version v0.2.2
* @version v0.3.0
*/

namespace AustinHeap\Database\Encryption\Tests\Defaults;
Expand Down
Loading