diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..db99962 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/.travis.yml b/.travis.yml index 3011cf1..988f99f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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 @@ -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 diff --git a/README.md b/README.md index c454787..3d003f7 100644 --- a/README.md +++ b/README.md @@ -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 * PHP [OpenSSL extension](http://php.net/manual/en/book.openssl.php) @@ -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 diff --git a/composer.json b/composer.json index 3a6112b..c037779 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "laravel56 encryption", "laravel57 encryption", "laravel58 encryption", + "laravel6 encryption", "eloquent encryption", "model encryption", "attribute encryption", @@ -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": { @@ -82,5 +83,8 @@ }, "config": { "discard-changes": true + }, + "scripts": { + "test": "vendor/bin/phpunit" } } diff --git a/config/database-encryption.php b/config/database-encryption.php index 35687bc..11720f0 100644 --- a/config/database-encryption.php +++ b/config/database-encryption.php @@ -3,7 +3,7 @@ * src/config/database-encryption.php. * * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ return [ diff --git a/phpunit.xml b/phpunit.xml index 63f8bc1..76bb0b8 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,7 +6,9 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" + convertDeprecationsToExceptions="false" processIsolation="false" + failOnWarning="false" stopOnFailure="false"> diff --git a/src/Console/Commands/MigrateEncryptionCommand.php b/src/Console/Commands/MigrateEncryptionCommand.php index 6f5a2b4..98bab8c 100644 --- a/src/Console/Commands/MigrateEncryptionCommand.php +++ b/src/Console/Commands/MigrateEncryptionCommand.php @@ -3,7 +3,7 @@ * src/Console/Commands/MigrateEncryptionCommand.php. * * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ declare(strict_types=1); diff --git a/src/EncryptionDefaults.php b/src/EncryptionDefaults.php index e829c95..d8f8d21 100644 --- a/src/EncryptionDefaults.php +++ b/src/EncryptionDefaults.php @@ -3,7 +3,7 @@ * src/EncryptionDefaults.php. * * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ declare(strict_types=1); diff --git a/src/EncryptionFacade.php b/src/EncryptionFacade.php index 9550492..002e5ed 100644 --- a/src/EncryptionFacade.php +++ b/src/EncryptionFacade.php @@ -3,7 +3,7 @@ * src/EncryptionFacade.php. * * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ declare(strict_types=1); diff --git a/src/EncryptionHelper.php b/src/EncryptionHelper.php index 179f1d2..500e8e2 100644 --- a/src/EncryptionHelper.php +++ b/src/EncryptionHelper.php @@ -3,7 +3,7 @@ * src/EncryptionHelper.php. * * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ declare(strict_types=1); diff --git a/src/EncryptionServiceProvider.php b/src/EncryptionServiceProvider.php index 8091b09..0ce8f1e 100644 --- a/src/EncryptionServiceProvider.php +++ b/src/EncryptionServiceProvider.php @@ -3,7 +3,7 @@ * src/EncryptionServiceProvider.php. * * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ declare(strict_types=1); diff --git a/src/Traits/HasEncryptedAttributes.php b/src/Traits/HasEncryptedAttributes.php index dd6cab3..2d54c68 100644 --- a/src/Traits/HasEncryptedAttributes.php +++ b/src/Traits/HasEncryptedAttributes.php @@ -3,7 +3,7 @@ * src/Traits/HasEncryptedAttributes.php. * * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ declare(strict_types=1); diff --git a/src/helpers.php b/src/helpers.php index c7d8376..4d50158 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -3,7 +3,7 @@ * src/helpers.php. * * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ declare(strict_types=1); @@ -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 + { + return \Illuminate\Support\Str::random($value); + } +} diff --git a/tests/Console/MigrateEncryptionTest.php b/tests/Console/MigrateEncryptionTest.php index 11c68d0..c8da52b 100644 --- a/tests/Console/MigrateEncryptionTest.php +++ b/tests/Console/MigrateEncryptionTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Console; @@ -13,6 +13,7 @@ use AustinHeap\Database\Encryption\Console\Commands\MigrateEncryptionCommand; use AustinHeap\Database\Encryption\Tests\DatabaseTestCase; use DatabaseEncryption; +use Illuminate\Support\Str; use RuntimeException; /** @@ -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']; } }; @@ -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); } }; @@ -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']; } }; diff --git a/tests/DatabaseTestCase.php b/tests/DatabaseTestCase.php index 31db31e..1aa047d 100644 --- a/tests/DatabaseTestCase.php +++ b/tests/DatabaseTestCase.php @@ -5,13 +5,14 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests; use AustinHeap\Database\Encryption\Tests\Models\DatabaseModel; use DB, RuntimeException; +use Illuminate\Support\Str; /** * DatabaseTestCase @@ -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(); @@ -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); } diff --git a/tests/Defaults/ControlCharactersTest.php b/tests/Defaults/ControlCharactersTest.php index 7a5bc7f..d954232 100644 --- a/tests/Defaults/ControlCharactersTest.php +++ b/tests/Defaults/ControlCharactersTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Defaults; diff --git a/tests/Defaults/EnabledTest.php b/tests/Defaults/EnabledTest.php index e74f3df..cfb0161 100644 --- a/tests/Defaults/EnabledTest.php +++ b/tests/Defaults/EnabledTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Defaults; diff --git a/tests/Defaults/HelpersTest.php b/tests/Defaults/HelpersTest.php index 13c3021..a915007 100644 --- a/tests/Defaults/HelpersTest.php +++ b/tests/Defaults/HelpersTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Defaults; diff --git a/tests/Defaults/PrefixTest.php b/tests/Defaults/PrefixTest.php index afbb703..b618ff3 100644 --- a/tests/Defaults/PrefixTest.php +++ b/tests/Defaults/PrefixTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Defaults; diff --git a/tests/Defaults/VersioningTest.php b/tests/Defaults/VersioningTest.php index 1ebe3b3..7faf2c4 100644 --- a/tests/Defaults/VersioningTest.php +++ b/tests/Defaults/VersioningTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Defaults; diff --git a/tests/Facade/FacadeTest.php b/tests/Facade/FacadeTest.php index 52d6941..3eefe98 100644 --- a/tests/Facade/FacadeTest.php +++ b/tests/Facade/FacadeTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests; diff --git a/tests/Helper/DisabledTest.php b/tests/Helper/DisabledTest.php index d29ee48..45ea83e 100644 --- a/tests/Helper/DisabledTest.php +++ b/tests/Helper/DisabledTest.php @@ -4,7 +4,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Helper; diff --git a/tests/Helper/EnabledTest.php b/tests/Helper/EnabledTest.php index 8be3d10..b324f51 100644 --- a/tests/Helper/EnabledTest.php +++ b/tests/Helper/EnabledTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Helper; diff --git a/tests/Helper/HeaderPrefixTest.php b/tests/Helper/HeaderPrefixTest.php index a7c3cb0..6f96c4e 100644 --- a/tests/Helper/HeaderPrefixTest.php +++ b/tests/Helper/HeaderPrefixTest.php @@ -4,7 +4,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Helper; diff --git a/tests/Helper/PrefixTest.php b/tests/Helper/PrefixTest.php index c9bb886..e87f15e 100644 --- a/tests/Helper/PrefixTest.php +++ b/tests/Helper/PrefixTest.php @@ -4,7 +4,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Helper; diff --git a/tests/Helper/SingletonTest.php b/tests/Helper/SingletonTest.php index b8269c6..d0c401d 100644 --- a/tests/Helper/SingletonTest.php +++ b/tests/Helper/SingletonTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Helper; diff --git a/tests/Helper/VersionPartsTest.php b/tests/Helper/VersionPartsTest.php index 168a3fb..bd7e9fe 100644 --- a/tests/Helper/VersionPartsTest.php +++ b/tests/Helper/VersionPartsTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Helper; diff --git a/tests/Helper/VersioningTest.php b/tests/Helper/VersioningTest.php index e7710d7..da33a60 100644 --- a/tests/Helper/VersioningTest.php +++ b/tests/Helper/VersioningTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Helper; diff --git a/tests/Helper/VersionlessTest.php b/tests/Helper/VersionlessTest.php index 4b0669f..73fae56 100644 --- a/tests/Helper/VersionlessTest.php +++ b/tests/Helper/VersionlessTest.php @@ -4,7 +4,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Helper; diff --git a/tests/Models/DatabaseModel.php b/tests/Models/DatabaseModel.php index f0b56a9..6fac2ef 100644 --- a/tests/Models/DatabaseModel.php +++ b/tests/Models/DatabaseModel.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Models; diff --git a/tests/Models/DummyModel.php b/tests/Models/DummyModel.php index 8aa632f..62a00a9 100644 --- a/tests/Models/DummyModel.php +++ b/tests/Models/DummyModel.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Models; diff --git a/tests/Models/FakeModel.php b/tests/Models/FakeModel.php index 4c8a7b7..b288bf0 100644 --- a/tests/Models/FakeModel.php +++ b/tests/Models/FakeModel.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Models; diff --git a/tests/Models/RealModel.php b/tests/Models/RealModel.php index e411869..d3702a0 100644 --- a/tests/Models/RealModel.php +++ b/tests/Models/RealModel.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Models; @@ -39,7 +39,12 @@ public function getRawValues(array $columns = null): ?array ); try { - $dsn = sprintf('mysql:dbname=%s;host=%s;charset=utf8', DB::getDatabaseName(), env('TESTING_DB_HOST', '127.0.0.1')); + $dsn = sprintf( + 'mysql:dbname=%s;host=%s;port=%s;charset=utf8', + DB::getDatabaseName(), + env('TESTING_DB_HOST', '127.0.0.1'), + env('TESTING_DB_PORT', 3306) + ); $connection = new PDO($dsn, env('TESTING_DB_USER', 'root'), env('TESTING_DB_PASS', '')); $statement = $connection->prepare($query); diff --git a/tests/TestCase.php b/tests/TestCase.php index f2f179a..58ad41c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests; @@ -13,6 +13,7 @@ use AustinHeap\Database\Encryption\EncryptionFacade; use AustinHeap\Database\Encryption\EncryptionServiceProvider; use DB, RuntimeException, ReflectionClass; +use Illuminate\Support\Str; use Orchestra\Testbench\TestCase as BaseTestCase; /** @@ -25,7 +26,7 @@ class TestCase extends BaseTestCase protected function getEnvironmentSetUp($app) { - $app['config']->set('app.key', str_random(32)); + $app['config']->set('app.key', Str::random(32)); $app['config']->set('database-encryption.enabled', true); } diff --git a/tests/Traits/DatabaseTest.php b/tests/Traits/DatabaseTest.php index 2d815c9..0c6cf0f 100644 --- a/tests/Traits/DatabaseTest.php +++ b/tests/Traits/DatabaseTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Traits; diff --git a/tests/Traits/DirtyTest.php b/tests/Traits/DirtyTest.php index a9289fc..c56f3c4 100644 --- a/tests/Traits/DirtyTest.php +++ b/tests/Traits/DirtyTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Traits; diff --git a/tests/Traits/DummyTest.php b/tests/Traits/DummyTest.php index 7268fdb..3988a52 100644 --- a/tests/Traits/DummyTest.php +++ b/tests/Traits/DummyTest.php @@ -5,13 +5,14 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Traits; use AustinHeap\Database\Encryption\Tests\TestCase; use AustinHeap\Database\Encryption\Tests\Models\DummyModel; +use Illuminate\Support\Str; /** * DummyTest @@ -32,8 +33,8 @@ protected function doTest($attributes) public function testEncryptNormalString() { $this->doTest([ - 'dont_encrypt' => 'dont-encrypt-' . str_random(), - 'encrypt_me' => 'encrypt-me-' . str_random(), + 'dont_encrypt' => 'dont-encrypt-' . Str::random(), + 'encrypt_me' => 'encrypt-me-' . Str::random(), ]); } @@ -41,7 +42,7 @@ public function testEncryptStringWithPlus() { $this->doTest([ 'dont_encrypt' => '12345+' . rand(111111, 999999) . '@gmail.com', - 'encrypt_me' => 'abcde+' . str_random() . '@gmail.com', + 'encrypt_me' => 'abcde+' . Str::random() . '@gmail.com', ]); } @@ -49,7 +50,7 @@ public function testIsEncryptable() { $attributes = [ 'dont_encrypt' => '12345+' . rand(111111, 999999) . '@gmail.com', - 'encrypt_me' => 'abcde+' . str_random() . '@gmail.com', + 'encrypt_me' => 'abcde+' . Str::random() . '@gmail.com', ]; $model = new DummyModel($attributes); diff --git a/tests/Traits/ExceptionTest.php b/tests/Traits/ExceptionTest.php index cf508c3..04b5d5d 100644 --- a/tests/Traits/ExceptionTest.php +++ b/tests/Traits/ExceptionTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Traits; diff --git a/tests/Traits/FloatTest.php b/tests/Traits/FloatTest.php index 1ae2959..becfdfb 100644 --- a/tests/Traits/FloatTest.php +++ b/tests/Traits/FloatTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Traits; diff --git a/tests/Traits/IntTest.php b/tests/Traits/IntTest.php index c2ddd24..6d2d802 100644 --- a/tests/Traits/IntTest.php +++ b/tests/Traits/IntTest.php @@ -5,7 +5,7 @@ * @package laravel-database-encryption * @link https://github.com/austinheap/laravel-database-encryption * @author Austin Heap - * @version v0.2.1 + * @version v0.3.0 */ namespace AustinHeap\Database\Encryption\Tests\Traits;