From 278b6f95b2677343837a77e466e009add9c71a82 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Fri, 14 Feb 2020 17:47:24 +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 09cc3e4fb33812edd115ab28bdf4902bfe85b96c Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Fri, 14 Feb 2020 17:59:09 +0100 Subject: [PATCH 2/2] Updating the package --- .editorconfig | 10 +++++----- .gitattributes | 1 - .scrutinizer.yml | 2 +- .travis.yml | 23 ----------------------- README.md | 11 +++++------ composer.json | 2 +- src/Contracts/HashDriver.php | 6 +++++- src/Contracts/HashManager.php | 6 +++++- src/Drivers/HashidsDriver.php | 6 +++++- src/HashManager.php | 10 +++++++--- src/HasherServiceProvider.php | 7 +++++-- tests/Drivers/HashidsDriverTest.php | 6 +++++- tests/HasherManagerTest.php | 26 +++++++++++++++----------- tests/HasherServiceProviderTest.php | 10 +++++++--- tests/Stubs/CustomHasherClient.php | 6 +++++- tests/TestCase.php | 10 +++++++--- 16 files changed, 78 insertions(+), 64 deletions(-) delete mode 100644 .travis.yml diff --git a/.editorconfig b/.editorconfig index 042d009..6537ca4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,15 +1,15 @@ -# This file is for unifying the coding style for different editors and IDEs -# editorconfig.org - root = true [*] -end_of_line = lf charset = utf-8 +end_of_line = lf +insert_final_newline = true indent_style = space indent_size = 4 trim_trailing_whitespace = true -insert_final_newline = true [*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] indent_size = 2 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 0f8720f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - - 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" != "nightly" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [ "$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 75ce5a9..30772b7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Hasher [![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] @@ -14,9 +14,9 @@ The Hasher package provides a flexible hash manager for Laravel. -This package offers [Hashids](https://github.com/ivanakimov/hashids.php) as default driver with multiple connections. +This package offers [Hashids](https://github.com/ivanakimov/hashids.php) as default driver with multiple connections. - > Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers. + > Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers. Feel free to check out the [releases](https://github.com/ARCANEDEV/Hasher/releases), [license](LICENSE.md), and [contribution guidelines](CONTRIBUTING.md). @@ -50,8 +50,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail. [badge_license]: https://img.shields.io/packagist/l/arcanedev/hasher.svg?style=flat-square [badge_laravel]: https://img.shields.io/badge/For%20Laravel-5.x%20|%206.x-orange.svg?style=flat-square - -[badge_build]: https://img.shields.io/travis/ARCANEDEV/Hasher.svg?style=flat-square +[badge_build]: https://img.shields.io/github/workflow/status/ARCANEDEV/Hasher/run-tests?style=flat-square [badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/Hasher.svg?style=flat-square [badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/Hasher.svg?style=flat-square [badge_insight]: https://img.shields.io/sensiolabs/i/0c427742-b488-4bff-87ed-cb1d59217d20.svg?style=flat-square @@ -63,9 +62,9 @@ If you discover any security related issues, please email arcanedev.maroc@gmail. [link-author]: https://github.com/arcanedev-maroc [link-github-repo]: https://github.com/ARCANEDEV/Hasher +[link-github-status]: https://github.com/ARCANEDEV/Hasher/actions [link-github-issues]: https://github.com/ARCANEDEV/Hasher/issues [link-contributors]: https://github.com/ARCANEDEV/Hasher/graphs/contributors [link-packagist]: https://packagist.org/packages/arcanedev/hasher -[link-travis]: https://travis-ci.org/ARCANEDEV/Hasher [link-scrutinizer]: https://scrutinizer-ci.com/g/ARCANEDEV/Hasher/?branch=master [link-insight]: https://insight.sensiolabs.com/projects/0c427742-b488-4bff-87ed-cb1d59217d20 diff --git a/composer.json b/composer.json index 150be62..0a2574c 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.1", "hashids/hashids": "^4.0" }, "require-dev": { diff --git a/src/Contracts/HashDriver.php b/src/Contracts/HashDriver.php index 03b0ebf..3d4fae1 100644 --- a/src/Contracts/HashDriver.php +++ b/src/Contracts/HashDriver.php @@ -1,4 +1,8 @@ -config('default.driver'); } @@ -61,7 +65,7 @@ public function getDefaultDriver() * * @return string */ - public function getDefaultOption() + public function getDefaultOption(): string { return $this->option ?? $this->config('default.option', 'main'); } diff --git a/src/HasherServiceProvider.php b/src/HasherServiceProvider.php index 0050743..749897b 100644 --- a/src/HasherServiceProvider.php +++ b/src/HasherServiceProvider.php @@ -1,4 +1,8 @@ -registerConfig(); - // Services $this->singleton(Contracts\HashManager::class, HashManager::class); } diff --git a/tests/Drivers/HashidsDriverTest.php b/tests/Drivers/HashidsDriverTest.php index 4163988..871ebbd 100644 --- a/tests/Drivers/HashidsDriverTest.php +++ b/tests/Drivers/HashidsDriverTest.php @@ -1,4 +1,8 @@ -manager->getDefaultDriver()); } /** @test */ - public function it_can_get_default_option() + public function it_can_get_default_option(): void { static::assertSame('main', $this->manager->getDefaultOption()); } /** @test */ - public function it_can_set_default_option() + public function it_can_set_default_option(): void { $this->manager->option('alt'); @@ -74,7 +78,7 @@ public function it_can_set_default_option() } /** @test */ - public function it_can_get_hash_driver_without_name() + public function it_can_get_hash_driver_without_name(): void { $driver = $this->manager->driver(); @@ -89,7 +93,7 @@ public function it_can_get_hash_driver_without_name() } /** @test */ - public function it_can_get_hash_driver_with_name() + public function it_can_get_hash_driver_with_name(): void { $driver = $this->manager->driver('custom'); @@ -104,7 +108,7 @@ public function it_can_get_hash_driver_with_name() } /** @test */ - public function it_can_get_hash_driver_with_name_and_option() + public function it_can_get_hash_driver_with_name_and_option(): void { $driver = $this->manager->with('alt', 'custom'); @@ -121,7 +125,7 @@ public function it_can_get_hash_driver_with_name_and_option() } /** @test */ - public function it_can_encode_and_decode() + public function it_can_encode_and_decode(): void { $value = 123456; $mainDriver = $this->manager->option('main')->driver(); @@ -138,7 +142,7 @@ public function it_can_encode_and_decode() } /** @test */ - public function it_can_encode_and_decode_with_helper() + public function it_can_encode_and_decode_with_helper(): void { $value = 123456; $mainDriver = hasher()->with('main'); @@ -155,7 +159,7 @@ public function it_can_encode_and_decode_with_helper() } /** @test */ - public function it_can_encode_and_decode_from_manager() + public function it_can_encode_and_decode_from_manager(): void { $value = 123456; $hashed = $this->manager->encode($value); diff --git a/tests/HasherServiceProviderTest.php b/tests/HasherServiceProviderTest.php index 1d26dad..89b53d1 100644 --- a/tests/HasherServiceProviderTest.php +++ b/tests/HasherServiceProviderTest.php @@ -1,4 +1,8 @@ -