From 5c6fa9d24122789d859490b28fe711d2aea91bba Mon Sep 17 00:00:00 2001 From: Hieu Le Date: Sat, 12 Oct 2019 10:31:10 +0700 Subject: [PATCH] Update to Laravel 6, PHPUnit 8 and new Travis CI code coverage --- .gitignore | 1 + .travis.yml | 14 ++++++-------- README.md | 7 ++++--- composer.json | 11 +++++------ phpunit.xml | 1 - src/Active.php | 8 +++----- src/ActiveServiceProvider.php | 18 +++++------------- src/helpers.php | 2 +- tests/.gitkeep | 0 tests/ActiveTest.php | 2 +- 10 files changed, 26 insertions(+), 38 deletions(-) delete mode 100644 tests/.gitkeep diff --git a/.gitignore b/.gitignore index 353c489..2090496 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ composer.lock .DS_Store /nbproject/private/ /.idea +/.phpunit.result.cache diff --git a/.travis.yml b/.travis.yml index e2df29e..2b3cc5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,21 +2,19 @@ sudo: false language: php -dist: trusty - php: - - 7.0 - -env: - - LARAVEL_VERSION="5.5.*" + - 7.2 + - 7.3 before_script: - composer self-update - - composer require laravel/framework:$LARAVEL_VERSION --no-update - composer install --prefer-source --no-interaction + - 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 script: - vendor/bin/phpunit --coverage-clover build/logs/clover.xml after_script: - - vendor/bin/test-reporter + - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi diff --git a/README.md b/README.md index ec58a1e..a63d934 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,12 @@ Active for Laravel [![Total Downloads](https://poser.pugx.org/hieu-le/active/downloads.svg)](https://packagist.org/packages/hieu-le/active) [![License](https://poser.pugx.org/hieu-le/active/license.svg)](https://packagist.org/packages/hieu-le/active) -The helper class for Laravel applications (both L4 and L5) to get active class base on current url. +The helper class for Laravel applications to get active class base on current url. -This README file is written for the new `3.x` version of this package, which is compatible with the Laravel 5 only. +This README file is written for the new `4.x` version of this package, which is compatible with the Laravel 6 only. * If you are using Laravel 4, see the [`1.x` versions](https://github.com/letrunghieu/active/tree/support/1.x). - * If you are using Laravel 5 with the legacy `2.x` version of this package, you can give a try with the `3.x` version (whose API is changed totally) or continue with the [`2.x` version](https://github.com/letrunghieu/active/tree/support/2.x). + * If you are using Laravel 5, see the [`3.x` versions](https://github.com/letrunghieu/active/tree/support/3.x) ## Installation @@ -41,6 +41,7 @@ See: [How to use Active](https://www.hieule.info/?p=377) ## Changelog: +* v4.0: support Laravel 6 and PHPUnit 8 * v3.5: support Laravel 5.5.x and PHPUnit 6 * v3.4: support Laravel 5.4.x * v3.3: support Laravel 5.3.x diff --git a/composer.json b/composer.json index 4e0283b..3de9824 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "hieu-le/active", - "description": "The helper class for Laravel (4/5) applications to get active class base on current route", + "description": "The helper class for Laravel applications to get active class base on current route", "keywords": [ "laravel", "active", @@ -16,13 +16,12 @@ } ], "require": { - "php": ">=7.0", - "laravel/framework": "^5.5" + "php": ">=7.2", + "laravel/framework": "^6.0" }, "require-dev": { - "phpunit/phpunit": "~6.0", - "codeclimate/php-test-reporter": "dev-master", - "orchestra/testbench": "^3.1" + "phpunit/phpunit": "^8.0", + "orchestra/testbench": "^4.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index 668750a..59f41ba 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -8,7 +8,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" > diff --git a/src/Active.php b/src/Active.php index e259004..6cce521 100644 --- a/src/Active.php +++ b/src/Active.php @@ -20,8 +20,6 @@ * * @package HieuLe\Active * @author Hieu Le - * @version 3.2.0 - * */ class Active { @@ -138,7 +136,7 @@ public function checkUri($uris) } /** - * Check if the current URI matches one of specific patterns (using `str_is`) + * Check if the current URI matches one of specific patterns (using `Str::is`) * * @param array|string $patterns * @@ -151,7 +149,7 @@ public function checkUriPattern($patterns) } foreach ((array)$patterns as $p) { - if (str_is($p, $this->uri)) { + if (Str::is($p, $this->uri)) { return true; } } @@ -233,7 +231,7 @@ public function checkRoutePattern($patterns) } foreach ((array)$patterns as $p) { - if (str_is($p, $routeName)) { + if (Str::is($p, $routeName)) { return true; } } diff --git a/src/ActiveServiceProvider.php b/src/ActiveServiceProvider.php index 6be2c86..d4d2159 100644 --- a/src/ActiveServiceProvider.php +++ b/src/ActiveServiceProvider.php @@ -20,19 +20,11 @@ public function boot() { // Update the instances each time a request is resolved and a route is matched $instance = app('active'); - if (version_compare(Application::VERSION, '5.2.0', '>=')) { - app('router')->matched( - function (RouteMatched $event) use ($instance) { - $instance->updateInstances($event->route, $event->request); - } - ); - } else { - app('router')->matched( - function ($route, $request) use ($instance) { - $instance->updateInstances($route, $request); - } - ); - } + app('router')->matched( + function (RouteMatched $event) use ($instance) { + $instance->updateInstances($event->route, $event->request); + } + ); } /** diff --git a/src/helpers.php b/src/helpers.php index 9cbd8de..afc6c01 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -32,7 +32,7 @@ function if_uri($uris) if (!function_exists('if_uri_pattern')) { /** - * Check if the current URI matches one of specific patterns (using `str_is`) + * Check if the current URI matches one of specific patterns (using `Str::is`) * * @param array|string $patterns * diff --git a/tests/.gitkeep b/tests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/ActiveTest.php b/tests/ActiveTest.php index c27eece..34ad56b 100644 --- a/tests/ActiveTest.php +++ b/tests/ActiveTest.php @@ -10,7 +10,7 @@ class ActiveTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp();