From 3f3cc3c27ddeb701428572dc1221ec8f5d2163a7 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Sat, 1 Feb 2020 16:20:23 +0100 Subject: [PATCH 1/2] Using GitHub Actions for testing --- .github/workflows/run-tests.yml | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..10b997e --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,46 @@ +name: run-tests + +on: [push] + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + php: [7.2, 7.3, 7.4] + laravel: [6.*] + dependency-version: [prefer-lowest, prefer-stable] + + name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v1 + with: + php-version: ${{ matrix.php }} + extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv + coverage: xdebug + + - name: Install dependencies + run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: | + mkdir -p build/logs + vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover + + - name: Scrutinizer CI + run: | + wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover coverage.clover From abf360a9c5fadbda5c4e8607414e14dfc89cae8b Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Sat, 1 Feb 2020 16:41:02 +0100 Subject: [PATCH 2/2] Updating the package --- .gitattributes | 1 - .scrutinizer.yml | 2 +- .travis.yml | 24 ------------------- README.md | 6 ++--- composer.json | 2 +- src/Contracts/Impersonatable.php | 6 ++++- src/Contracts/Impersonator.php | 6 ++++- src/Events/AbstractImpersonationEvent.php | 6 ++++- src/Events/ImpersonationStarted.php | 6 ++++- src/Events/ImpersonationStopped.php | 6 ++++- src/Exceptions/ImpersonationException.php | 10 +++++--- src/Guard/SessionGuard.php | 6 ++++- .../Middleware/ImpersonationNotAllowed.php | 6 ++++- src/Impersonator.php | 12 ++++++---- src/ImpersonatorServiceProvider.php | 6 ++++- src/Policies/ImpersonationPolicy.php | 6 ++++- .../AuthorizationServiceProvider.php | 6 ++++- src/Traits/CanImpersonate.php | 6 ++++- tests/EventsTest.php | 6 ++++- tests/ImpersonationPoliciesTest.php | 6 ++++- tests/ImpersonationTraitTest.php | 6 ++++- tests/ImpersonatorServiceProviderTest.php | 6 ++++- tests/ImpersonatorTest.php | 6 ++++- tests/MiddlewareTest.php | 6 ++++- .../Controllers/ImpersonatorController.php | 6 ++++- tests/Stubs/Models/User.php | 6 ++++- tests/TestCase.php | 6 ++++- 27 files changed, 120 insertions(+), 57 deletions(-) delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index 7ccb1f3..22f739a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,6 +7,5 @@ .gitattributes export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore -.travis.yml export-ignore phpunit.xml.dist export-ignore CONTRIBUTING.md export-ignore diff --git a/.scrutinizer.yml b/.scrutinizer.yml index d44a72f..8a9285f 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -22,7 +22,7 @@ checks: tools: external_code_coverage: timeout: 600 - runs: 2 + runs: 6 php_code_sniffer: enabled: true config: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d43d90e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - - 7.4snapshot - - nightly - -matrix: - allow_failures: - - php: nightly - -before_script: - - travis_retry composer self-update - - travis_retry composer install --prefer-source --no-interaction - -script: - - composer validate - - mkdir -p build/logs - - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - -after_script: - - if [ "$TRAVIS_PHP_VERSION" != "7.4snapshot" ] && [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [ "$TRAVIS_PHP_VERSION" != "7.4snapshot" ] && [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/README.md b/README.md index 4f5a6e7..4cad83f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LaravelImpersonator [![Packagist License][badge_license]](LICENSE.md) [![For Laravel][badge_laravel]][link-github-repo] -[![Travis Status][badge_build]][link-travis] +[![Github Workflow Status][badge_build]][link-github-status] [![Coverage Status][badge_coverage]][link-scrutinizer] [![Scrutinizer Code Quality][badge_quality]][link-scrutinizer] [![SensioLabs Insight][badge_insight]][link-insight] @@ -45,7 +45,7 @@ Any ideas are welcome. Feel free to submit any issues or pull requests, please c [badge_license]: https://img.shields.io/packagist/l/arcanedev/laravel-impersonator.svg?style=flat-square [badge_laravel]: https://img.shields.io/badge/Laravel-5.4%20to%206.x-orange.svg?style=flat-square -[badge_build]: https://img.shields.io/travis/ARCANEDEV/LaravelImpersonator.svg?style=flat-square +[badge_build]: https://img.shields.io/github/workflow/status/ARCANEDEV/LaravelImpersonator/run-tests?style=flat-square [badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/LaravelImpersonator.svg?style=flat-square [badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/LaravelImpersonator.svg?style=flat-square [badge_insight]: https://img.shields.io/sensiolabs/i/a9bfffe8-8d21-434c-a1cc-07bbbee97cb7.svg?style=flat-square @@ -56,9 +56,9 @@ Any ideas are welcome. Feel free to submit any issues or pull requests, please c [link-author]: https://github.com/arcanedev-maroc [link-github-repo]: https://github.com/ARCANEDEV/LaravelImpersonator +[link-github-status]: https://github.com/ARCANEDEV/LaravelImpersonator/actions [link-github-issues]: https://github.com/ARCANEDEV/LaravelImpersonator/issues [link-contributors]: https://github.com/ARCANEDEV/LaravelImpersonator/graphs/contributors [link-packagist]: https://packagist.org/packages/arcanedev/laravel-impersonator -[link-travis]: https://travis-ci.org/ARCANEDEV/LaravelImpersonator [link-scrutinizer]: https://scrutinizer-ci.com/g/ARCANEDEV/LaravelImpersonator/?branch=master [link-insight]: https://insight.sensiolabs.com/projects/a9bfffe8-8d21-434c-a1cc-07bbbee97cb7 diff --git a/composer.json b/composer.json index 77a1034..0056371 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "license": "MIT", "require": { "php": ">=7.2.0", - "arcanedev/support": "^5.0" + "arcanedev/support": "^5.1" }, "require-dev": { "orchestra/testbench": "^4.0", diff --git a/src/Contracts/Impersonatable.php b/src/Contracts/Impersonatable.php index bfb47e1..4f62b63 100644 --- a/src/Contracts/Impersonatable.php +++ b/src/Contracts/Impersonatable.php @@ -1,4 +1,8 @@ - */ -class Impersonator implements Contracts\Impersonator +class Impersonator implements ImpersonatorContract { /* ----------------------------------------------------------------- | Properties @@ -183,7 +188,7 @@ public function findUserById($id) } /* ----------------------------------------------------------------- - | Check Functions + | Check Methods | ----------------------------------------------------------------- */ @@ -276,7 +281,6 @@ private function checkImpersonater(Impersonatable $impersonater): void */ private function checkImpersonated(Impersonatable $impersonated): void { - if ( ! $impersonated->canBeImpersonated()) throw ImpersonationException::cannotBeImpersonated($impersonated); } diff --git a/src/ImpersonatorServiceProvider.php b/src/ImpersonatorServiceProvider.php index 6da5da6..31b60d1 100644 --- a/src/ImpersonatorServiceProvider.php +++ b/src/ImpersonatorServiceProvider.php @@ -1,4 +1,8 @@ -