Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

⬆️ draft support for laravel 6.* #53

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 13 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ matrix:
env: LARAVEL=57
- php: 7.2
env: LARAVEL=58
- php: 7.2
env: LARAVEL=6x
- php: 7.3
env: LARAVEL=55
- php: 7.3
Expand All @@ -26,26 +28,19 @@ matrix:
env: LARAVEL=57
- php: 7.3
env: LARAVEL=58
- php: 7.3
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 @@ -68,10 +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: 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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ directory. The most logical place to start are the [docs for the `HasEncryptedAt

## Requirements

* Laravel: 5.5, 5.6, 5.7, or 5.8
* Laravel: 5.5, 5.6, 5.7, 5.8, or 6.x
* PHP: 7.1, 7.2, or 7.3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since 7.1 is already deprecated and 7.2 is in security-only, maybe also look into PHP 7.4 support (add allow-failure CI tests for example)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, That's good idea. For now I was just looking into my own case where i needed Laravel 6 and php 7.3 support.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that should be a separate PR. There will probably be some issues.

* PHP [OpenSSL extension](http://php.net/manual/en/book.openssl.php)

Expand All @@ -75,6 +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.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
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"laravel56 encryption",
"laravel57 encryption",
"laravel58 encryption",
"laravel6 encryption",
"eloquent encryption",
"model encryption",
"attribute encryption",
Expand Down Expand Up @@ -54,12 +55,12 @@
},
"require": {
"php": ">=7.1.0",
"laravel/framework": "5.5.*|5.6.*|5.7.*|5.8.*"
"laravel/framework": "5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0"
},
"require-dev": {
"codeclimate/php-test-reporter": "dev-master",
"phpunit/phpunit": "~6.0|~7.0",
"orchestra/testbench": "^3.5"
"phpunit/phpunit": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
"orchestra/testbench": "^3.5|^4.0|^5.0|^6.0"
},
"autoload": {
"psr-4": {
Expand All @@ -82,5 +83,8 @@
},
"config": {
"discard-changes": true
},
"scripts": {
"test": "vendor/bin/phpunit"
}
}
2 changes: 1 addition & 1 deletion config/database-encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* src/config/database-encryption.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.2.1
* @version v0.3.0
*/

return [
Expand Down
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 <me@austinheap.com>
* @version v0.2.1
* @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 <me@austinheap.com>
* @version v0.2.1
* @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 <me@austinheap.com>
* @version v0.2.1
* @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 <me@austinheap.com>
* @version v0.2.1
* @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 <me@austinheap.com>
* @version v0.2.1
* @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 <me@austinheap.com>
* @version v0.2.1
* @version v0.3.0
*/
declare(strict_types=1);

Expand Down
14 changes: 13 additions & 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 <me@austinheap.com>
* @version v0.2.1
* @version v0.3.0
*/
declare(strict_types=1);

Expand Down Expand Up @@ -96,3 +96,15 @@ function dbdecrypt(string $value): ?string
return database_decrypt($value);
}
}

if (! function_exists('str_random')) {

/**
* @param int $value
* @return string|null
*/
function str_random(int $value = 16): ?string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Just replace it with Illuminate\Support\Str::random() if it's even being used anywhere.

{
return \Illuminate\Support\Str::random($value);
}
}
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 <me@austinheap.com>
* @version v0.2.1
* @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
Loading