From dd4535c78556e58db0a0815333f57e197ae59379 Mon Sep 17 00:00:00 2001 From: Richan Fongdasen Date: Thu, 5 Sep 2019 09:24:43 +0700 Subject: [PATCH] Add support for Laravel 6.0 and dropped some support for some older versions of Laravel. (#15) * Add support for Laravel 6.0 and dropped support for some older versions. * Fixes code quality issue * Fixes typo in orchestra package version --- .travis.yml | 10 +++------- composer.json | 16 ++++++++-------- src/Concerns/ManageEtagHeader.php | 7 +++++-- .../Supports/database/factories/UserFactory.php | 5 +++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7c0d000..263792f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,16 +5,12 @@ dist: trusty matrix: fast_finish: true include: - - php: 7.1 - env: LARAVEL=5.5.* ORCHESTRA=3.5.* - - php: 7.1 - env: LARAVEL=5.6.* ORCHESTRA=3.6.* - php: 7.2 - env: LARAVEL=5.7.* ORCHESTRA=3.7.* + env: LARAVEL=5.8.* ORCHESTRA=3.8.* - php: 7.2 - env: LARAVEL=5.8.* ORCHESTRA=3.8.* COVERAGE=1 + env: LARAVEL=6.0.* ORCHESTRA=4.0.* COVERAGE=1 - php: 7.3 - env: LARAVEL=5.8.* ORCHESTRA=3.8.* + env: LARAVEL=6.0.* ORCHESTRA=4.0.* allow_failures: - env: COVERAGE=1 diff --git a/composer.json b/composer.json index 941f7fe..cbc1443 100644 --- a/composer.json +++ b/composer.json @@ -21,21 +21,21 @@ "source": "https://github.com/richan-fongdasen/laravel-varnishable" }, "require": { - "php": "^7.1.3", + "php": "^7.2", "guzzlehttp/guzzle": "~6.0", - "illuminate/database": "5.5.*|5.6.*|5.7.*|5.8.*", - "illuminate/support": "5.5.*|5.6.*|5.7.*|5.8.*" + "illuminate/database": "5.8.*|6.0.*", + "illuminate/support": "5.8.*|6.0.*" }, "require-dev": { "mockery/mockery": "~1.0", - "orchestra/database": "~3.5", - "orchestra/testbench": "~3.5", + "orchestra/database": "~3.8|~4.0", + "orchestra/testbench": "~3.8|~4.0", "phpmd/phpmd": "^2.6", - "phpstan/phpstan": "^0.11.8", + "phpstan/phpstan": "^0.11.15", "phpstan/phpstan-deprecation-rules": "^0.11.2", "phpstan/phpstan-strict-rules": "^0.11.1", - "phpunit/phpunit": "^8.0 || ~7.0 || ~6.0", - "sebastian/phpcpd": "^4.1 || ~3.0" + "phpunit/phpunit": "^7.5|^8.0", + "sebastian/phpcpd": "^4.1" }, "config": { "sort-packages": true diff --git a/src/Concerns/ManageEtagHeader.php b/src/Concerns/ManageEtagHeader.php index 4a14a3c..ffc5258 100644 --- a/src/Concerns/ManageEtagHeader.php +++ b/src/Concerns/ManageEtagHeader.php @@ -15,8 +15,11 @@ trait ManageEtagHeader */ protected function addEtagHeader(Response $response) :void { - if ((bool) $this->getConfig('use_etag')) { - $response->setEtag(md5($response->getContent())); + $useEtag = (bool) $this->getConfig('use_etag'); + $content = $response->getContent(); + + if (($content !== false) && $useEtag) { + $response->setEtag(md5($content)); } } diff --git a/tests/Supports/database/factories/UserFactory.php b/tests/Supports/database/factories/UserFactory.php index a59d7e5..30ec5ab 100644 --- a/tests/Supports/database/factories/UserFactory.php +++ b/tests/Supports/database/factories/UserFactory.php @@ -1,5 +1,6 @@ define(User::class, function (\Faker\Generator $faker) { @@ -8,8 +9,8 @@ return [ 'name' => $faker->name, 'email' => $faker->email, - 'password' => bcrypt(str_random(12)), - 'remember_token' => str_random(12), + 'password' => bcrypt(Str::random(12)), + 'remember_token' => Str::random(12), 'created_at' => '2016-01-01 00:00:00', 'updated_at' => date('Y-m-d H:i:s', $time), ];