From 187a8a1afb3796561176f91c42468c04e8eb0280 Mon Sep 17 00:00:00 2001 From: Frederik Sauer Date: Wed, 12 Jun 2024 15:16:14 +0200 Subject: [PATCH 1/5] Laravel 11 support and dropped support for Laravel <9 --- .github/workflows/tests.yml | 112 ++++++++++++------------------------ .gitignore | 3 +- README.md | 5 -- composer.json | 17 +++--- phpunit.xml | 15 ++--- 5 files changed, 55 insertions(+), 97 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c164d39..e8ca3f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,94 +1,58 @@ name: Tests -on: [push, pull_request] +on: + workflow_dispatch: + push: + branches: + - master + paths: + - "**.json" + - "**.php" + - "**.yml" + pull_request: + branches: + - master + paths: + - "**.json" + - "**.php" + - "**.yml" jobs: tests: - runs-on: ${{ matrix.os }} strategy: fail-fast: true matrix: - os: [ubuntu-latest] - php: [8.1, 8.0, 7.4] - laravel: [10.*, 9.*, 8.*, 7.*, 6.*, 5.8.*, 5.7.*, 5.6.*] - dependency-version: [prefer-lowest, prefer-stable] - include: - - laravel: 10.* - testbench: ^8.0 - - laravel: 9.* - testbench: ^7.0 - - laravel: 8.* - testbench: ^6.23 - - laravel: 7.* - testbench: ^5.20 - - laravel: 6.* - testbench: ^4.18 - - laravel: 5.8.* - testbench: 3.8.* - - laravel: 5.7.* - testbench: 3.7.* - - laravel: 5.6.* - testbench: 3.6.* + php: [8.3, 8.2, 8.1, 8.0] + testbench: [9.0, 8.0, 7.0] # Laravel 11.x, 10.x, 9.x + version: [prefer-stable, prefer-lowest] exclude: - - laravel: 10.* - php: 8.0 - - laravel: 10.* - php: 7.4 - - laravel: 9.* - php: 7.4 - - laravel: 7.* - php: 8.1 - - laravel: 6.* - php: 8.1 - - laravel: 5.8.* - php: 8.1 - - laravel: 5.8.* - php: 8.0 - - laravel: 5.8.* - php: 7.4 - dependency-version: prefer-lowest - - laravel: 5.7.* - php: 8.1 - - laravel: 5.7.* - php: 8.0 - - laravel: 5.7.* - php: 7.4 - dependency-version: prefer-lowest - - laravel: 5.6.* - php: 8.1 - - laravel: 5.6.* - php: 8.0 - - laravel: 5.6.* - php: 7.4 - dependency-version: prefer-lowest + - php: 8.1 + testbench: 9.0 + - php: 8.0 + testbench: 9.0 + - php: 8.0 + testbench: 8.0 - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} + name: P${{ matrix.php }} - T${{ matrix.testbench }} - ${{ matrix.version }} - steps: - - name: Checkout code - uses: actions/checkout@v2 + runs-on: ubuntu-latest - - name: Install SQLite 3 - run: | - sudo apt-get update - sudo apt-get install sqlite3 + container: + image: kirschbaumdevelopment/laravel-test-runner:${{ matrix.php }} + options: "--user=root" - - name: Setup PHP - uses: shivammathur/setup-php@v2 + steps: + - name: Checkout code + uses: actions/checkout@v4 with: - php-version: ${{ matrix.php }} - extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv - coverage: none + # Make sure the actual branch is checked out when running on pull requests. + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction - - - name: Setup Problem Matches - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + composer require "orchestra/testbench:^${{ matrix.testbench }}" --no-interaction --no-update + composer update --${{ matrix.version }} --prefer-dist --no-interaction - name: Execute tests run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index 620dcaa..c3cd9c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ /vendor -/tests/_reports /.idea /composer.lock -/.phpunit.result.cache +/.phpunit.cache /.php-cs-fixer.cache diff --git a/README.md b/README.md index b2692a5..153890c 100644 --- a/README.md +++ b/README.md @@ -298,11 +298,6 @@ Running tests can be done either through composer, or directly calling the PHPUn ```bash composer test ``` -To run tests with code coverage, please make sure that `phpdbg` exists and is executable. -```bash -composer test-coverage -open tests/_reports/index.html -``` ## License The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/composer.json b/composer.json index f6a73e9..9b8ff8a 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "frittenkeez/laravel-vouchers", - "description": "Voucher system for Laravel 5.6+", + "description": "Voucher system for Laravel 9+", "license": "MIT", "keywords": [ "coupon", @@ -16,15 +16,15 @@ } ], "require": { - "php": "^7.1.3|^8.0", - "illuminate/config": "~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/console": "~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/database": "~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/support": "~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0" + "php": "^8.0", + "illuminate/config": "^9.0|^10.0|^11.0", + "illuminate/console": "^9.0|^10.0|^11.0", + "illuminate/database": "^9.0|^10.0|^11.0", + "illuminate/support": "^9.0|^10.0|^11.0" }, "require-dev": { - "orchestra/testbench": "~3.6.0|~3.7.0|~3.8.0|^4.0|^5.0|^6.0|^7.0|^8.0", - "phpunit/phpunit": "~7.0|^8.0|^9.0", + "orchestra/testbench": "^7.0|^8.0|^9.0", + "phpunit/phpunit": "^9.6", "friendsofphp/php-cs-fixer": "^3.4" }, "config": { @@ -48,7 +48,6 @@ }, "scripts": { "test": "phpunit", - "test-coverage": "phpdbg -qrr vendor/bin/phpunit --coverage-html tests/_reports", "fixer-check": "php-cs-fixer fix --verbose --dry-run", "fixer-fix": "php-cs-fixer fix" }, diff --git a/phpunit.xml b/phpunit.xml index 44f6dcc..afbf65c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,6 @@ + stopOnFailure="false" +> + + + src + + ./tests - - - src - - From eb57648d8581e0834030ba097a6190c3721cf58e Mon Sep 17 00:00:00 2001 From: Frederik Sauer Date: Wed, 12 Jun 2024 15:20:52 +0200 Subject: [PATCH 2/5] Manual version handling for runner --- .github/workflows/tests.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e8ca3f0..3715cf7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,6 +25,15 @@ jobs: php: [8.3, 8.2, 8.1, 8.0] testbench: [9.0, 8.0, 7.0] # Laravel 11.x, 10.x, 9.x version: [prefer-stable, prefer-lowest] + include: + - php: 8.3 + runner: "8.3" + - php: 8.2 + runner: "8.2" + - php: 8.1 + runner: "8.1" + - php: 8.0 + runner: "8.0" exclude: - php: 8.1 testbench: 9.0 @@ -38,7 +47,7 @@ jobs: runs-on: ubuntu-latest container: - image: kirschbaumdevelopment/laravel-test-runner:${{ matrix.php }} + image: kirschbaumdevelopment/laravel-test-runner:${{ matrix.runner }} options: "--user=root" steps: From 0a90eacf2d66ba328015bbe3307141adfbd68b76 Mon Sep 17 00:00:00 2001 From: Frederik Sauer Date: Wed, 12 Jun 2024 15:32:42 +0200 Subject: [PATCH 3/5] Drop support for PHP 8.0 --- .github/workflows/tests.yml | 17 ++--------------- composer.json | 4 ++-- phpunit.xml | 18 ++++++++---------- tests/VouchersTest.php | 2 +- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3715cf7..9fde0ea 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,32 +22,19 @@ jobs: strategy: fail-fast: true matrix: - php: [8.3, 8.2, 8.1, 8.0] + php: [8.3, 8.2, 8.1] testbench: [9.0, 8.0, 7.0] # Laravel 11.x, 10.x, 9.x version: [prefer-stable, prefer-lowest] - include: - - php: 8.3 - runner: "8.3" - - php: 8.2 - runner: "8.2" - - php: 8.1 - runner: "8.1" - - php: 8.0 - runner: "8.0" exclude: - php: 8.1 testbench: 9.0 - - php: 8.0 - testbench: 9.0 - - php: 8.0 - testbench: 8.0 name: P${{ matrix.php }} - T${{ matrix.testbench }} - ${{ matrix.version }} runs-on: ubuntu-latest container: - image: kirschbaumdevelopment/laravel-test-runner:${{ matrix.runner }} + image: kirschbaumdevelopment/laravel-test-runner:${{ matrix.php }} options: "--user=root" steps: diff --git a/composer.json b/composer.json index 9b8ff8a..2ae4eef 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "illuminate/config": "^9.0|^10.0|^11.0", "illuminate/console": "^9.0|^10.0|^11.0", "illuminate/database": "^9.0|^10.0|^11.0", @@ -24,7 +24,7 @@ }, "require-dev": { "orchestra/testbench": "^7.0|^8.0|^9.0", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^10.5", "friendsofphp/php-cs-fixer": "^3.4" }, "config": { diff --git a/phpunit.xml b/phpunit.xml index afbf65c..b9e164b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,21 +1,14 @@ - - - src - - ./tests @@ -25,4 +18,9 @@ + + + src + + diff --git a/tests/VouchersTest.php b/tests/VouchersTest.php index 4e21583..846d0c7 100644 --- a/tests/VouchersTest.php +++ b/tests/VouchersTest.php @@ -253,7 +253,7 @@ public function testInvalidMagicCall(): void * * @return array */ - public function wrapProvider(): array + public static function wrapProvider(): array { return [ 'string only' => ['code', null, null, '-', 'code'], From 59aed0957f15e333bf0e5a718afc65ed895d43ed Mon Sep 17 00:00:00 2001 From: Frederik Sauer Date: Wed, 12 Jun 2024 15:46:23 +0200 Subject: [PATCH 4/5] Re-adding PHPUnit 9.6 --- .github/workflows/tests.yml | 5 ++++- composer.json | 2 +- phpunit-9.xml | 29 +++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 phpunit-9.xml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9fde0ea..7f16098 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,6 +25,9 @@ jobs: php: [8.3, 8.2, 8.1] testbench: [9.0, 8.0, 7.0] # Laravel 11.x, 10.x, 9.x version: [prefer-stable, prefer-lowest] + include: + - testbench: 7.0 + phpunit: "-c phpunit-9.xml" exclude: - php: 8.1 testbench: 9.0 @@ -51,4 +54,4 @@ jobs: composer update --${{ matrix.version }} --prefer-dist --no-interaction - name: Execute tests - run: vendor/bin/phpunit + run: vendor/bin/phpunit ${{ matrix.phpunit }} diff --git a/composer.json b/composer.json index 2ae4eef..3181945 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "require-dev": { "orchestra/testbench": "^7.0|^8.0|^9.0", - "phpunit/phpunit": "^10.5", + "phpunit/phpunit": "^9.6|^10.5", "friendsofphp/php-cs-fixer": "^3.4" }, "config": { diff --git a/phpunit-9.xml b/phpunit-9.xml new file mode 100644 index 0000000..962aabf --- /dev/null +++ b/phpunit-9.xml @@ -0,0 +1,29 @@ + + + + + src + + + + + ./tests + + + + + + + From dbfb8463cd1498541145238e056efee4ebf64715 Mon Sep 17 00:00:00 2001 From: Frederik Sauer Date: Wed, 12 Jun 2024 16:00:52 +0200 Subject: [PATCH 5/5] Fix lowest libraries requirement --- .gitignore | 1 + composer.json | 6 ++++-- phpunit-9.xml | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c3cd9c2..09b9eba 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /.idea /composer.lock /.phpunit.cache +/.phpunit.result.cache /.php-cs-fixer.cache diff --git a/composer.json b/composer.json index 3181945..9388a85 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,11 @@ "illuminate/support": "^9.0|^10.0|^11.0" }, "require-dev": { + "friendsofphp/php-cs-fixer": "^3.4", + "illuminate/support": "^9.45|^10.0|^11.0", + "nesbot/carbon": "^2.63", "orchestra/testbench": "^7.0|^8.0|^9.0", - "phpunit/phpunit": "^9.6|^10.5", - "friendsofphp/php-cs-fixer": "^3.4" + "phpunit/phpunit": "^9.6|^10.5" }, "config": { "allow-plugins": { diff --git a/phpunit-9.xml b/phpunit-9.xml index 962aabf..afbf65c 100644 --- a/phpunit-9.xml +++ b/phpunit-9.xml @@ -4,7 +4,6 @@ backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" - cacheResultFile=".phpunit.cache" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true"