From a15a4b7ea884c973149662693f86c2c680780866 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 28 Jan 2025 23:14:11 +0800 Subject: [PATCH] Supports Laravel 12 (#1736) * Supports Laravel 12 Signed-off-by: Mior Muhammad Zaki * wip Signed-off-by: Mior Muhammad Zaki * wip Signed-off-by: Mior Muhammad Zaki * wip Signed-off-by: Mior Muhammad Zaki --------- Signed-off-by: Mior Muhammad Zaki --- .github/workflows/tests.yml | 38 +++++++++++++++++++++++-------- composer.json | 24 +++++++++---------- tests/Feature/FeatureTestCase.php | 6 ++++- tests/TestCase.php | 2 +- 4 files changed, 46 insertions(+), 24 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6968cf6c..be75ac43 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,14 +17,8 @@ jobs: fail-fast: true matrix: php: [8.1, 8.2, 8.3, 8.4] - laravel: [10, 11] - exclude: - - php: 8.1 - laravel: 11 - - php: 8.4 - laravel: 10 - name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} + name: PHP ${{ matrix.php }} steps: - name: Checkout code @@ -39,11 +33,35 @@ jobs: tools: composer:v2 coverage: none - - name: Install dependencies + - name: Install dependencies (Laravel 10) run: | - composer update --prefer-dist --no-interaction --no-progress --with="illuminate/contracts=^${{ matrix.laravel }}" + composer update --prefer-dist --no-interaction --no-progress --with="illuminate/contracts:^10" + if: matrix.php >= 8.1 && matrix.php < 8.4 - - name: Execute tests + - name: Execute tests (Laravel 10) run: vendor/bin/phpunit --display-deprecations --fail-on-deprecation + if: matrix.php >= 8.1 && matrix.php < 8.4 + env: + STRIPE_SECRET: ${{ secrets.STRIPE_SECRET }} + + - name: Install dependencies (Laravel 11) + run: | + composer update --prefer-dist --no-interaction --no-progress --with="illuminate/contracts:^11" + if: matrix.php >= 8.2 && matrix.php <= 8.4 + + - name: Execute tests (Laravel 11) + run: vendor/bin/phpunit --display-deprecations --fail-on-deprecation + if: matrix.php >= 8.2 && matrix.php <= 8.4 + env: + STRIPE_SECRET: ${{ secrets.STRIPE_SECRET }} + + - name: Install dependencies (Laravel 12) + run: | + composer update --prefer-dist --no-interaction --no-progress --with="illuminate/contracts:^12" + if: matrix.php >= 8.2 && matrix.php <= 8.4 + + - name: Execute tests (Laravel 12) + run: vendor/bin/phpunit --display-deprecations --fail-on-deprecation + if: matrix.php >= 8.2 && matrix.php <= 8.4 env: STRIPE_SECRET: ${{ secrets.STRIPE_SECRET }} diff --git a/composer.json b/composer.json index b0fc246f..651eb505 100644 --- a/composer.json +++ b/composer.json @@ -20,16 +20,16 @@ "require": { "php": "^8.1", "ext-json": "*", - "illuminate/console": "^10.0|^11.0", - "illuminate/contracts": "^10.0|^11.0", - "illuminate/database": "^10.0|^11.0", - "illuminate/http": "^10.0|^11.0", - "illuminate/log": "^10.0|^11.0", - "illuminate/notifications": "^10.0|^11.0", - "illuminate/pagination": "^10.0|^11.0", - "illuminate/routing": "^10.0|^11.0", - "illuminate/support": "^10.0|^11.0", - "illuminate/view": "^10.0|^11.0", + "illuminate/console": "^10.0|^11.0|^12.0", + "illuminate/contracts": "^10.0|^11.0|^12.0", + "illuminate/database": "^10.0|^11.0|^12.0", + "illuminate/http": "^10.0|^11.0|^12.0", + "illuminate/log": "^10.0|^11.0|^12.0", + "illuminate/notifications": "^10.0|^11.0|^12.0", + "illuminate/pagination": "^10.0|^11.0|^12.0", + "illuminate/routing": "^10.0|^11.0|^12.0", + "illuminate/support": "^10.0|^11.0|^12.0", + "illuminate/view": "^10.0|^11.0|^12.0", "moneyphp/money": "^4.0", "nesbot/carbon": "^2.0|^3.0", "stripe/stripe-php": "^16.2", @@ -40,9 +40,9 @@ "require-dev": { "dompdf/dompdf": "^2.0", "mockery/mockery": "^1.0", - "orchestra/testbench": "^8.18|^9.0", + "orchestra/testbench": "^8.18|^9.0|^10.0", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.4" + "phpunit/phpunit": "^10.4|^11.5" }, "suggest": { "ext-intl": "Allows for more locales besides the default \"en\" when formatting money values.", diff --git a/tests/Feature/FeatureTestCase.php b/tests/Feature/FeatureTestCase.php index 8046a2d0..4dde4672 100644 --- a/tests/Feature/FeatureTestCase.php +++ b/tests/Feature/FeatureTestCase.php @@ -6,14 +6,18 @@ use Laravel\Cashier\Cashier; use Laravel\Cashier\Tests\Fixtures\User; use Laravel\Cashier\Tests\TestCase; +use Orchestra\Testbench\Attributes\RequiresEnv; use Orchestra\Testbench\Concerns\WithLaravelMigrations; use Stripe\ApiRequestor as StripeApiRequestor; use Stripe\HttpClient\CurlClient as StripeCurlClient; use Stripe\StripeClient; +#[RequiresEnv('STRIPE_SECRET')] +#[WithMigration] abstract class FeatureTestCase extends TestCase { - use RefreshDatabase, WithLaravelMigrations; + use RefreshDatabase; + use WithLaravelMigrations; protected function setUp(): void { diff --git a/tests/TestCase.php b/tests/TestCase.php index 8f0e47ca..c3a56fd0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -13,7 +13,7 @@ abstract class TestCase extends OrchestraTestCase { use WithWorkbench; - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { $apiKey = config('cashier.secret');