From bf184973f943216b2aaa8dbc79631ea806038bb1 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 14 Feb 2025 05:03:57 +0800 Subject: [PATCH] Supports Laravel 12 (#125) * Supports Laravel 12 * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update SushiTest.php --- .github/workflows/tests.yml | 41 +++++++++++++++++++++++++++++++------ composer.json | 8 ++++---- tests/SushiTest.php | 21 ++++++++++++++++--- 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 057ba4a..16abcdf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,14 +12,16 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - php: [7.1, 7.2, 7.3, 7.4, '8.0', 8.1, 8.2, 8.3] - laravel: [5.8.*, 6.*, 7.*, 8.*, 9.*, 10.*, 11.*] + php: [7.1, 7.2, 7.3, 7.4, '8.0', 8.1, 8.2, 8.3, 8.4] + laravel: [5.8.*, 6.*, 7.*, 8.*, 9.*, 10.*, 11.*, 12.*] os: [ubuntu-latest] include: + - laravel: 12.* + testbench: 10.* - laravel: 11.* testbench: 9.* - dbal: 3.* - laravel: 10.* testbench: 8.* dbal: 3.* @@ -47,6 +49,8 @@ jobs: php: 8.2 - laravel: 5.8.* php: 8.3 + - laravel: 5.8.* + php: 8.4 - laravel: 6.* php: 7.1 - laravel: 6.* @@ -55,6 +59,8 @@ jobs: php: 8.2 - laravel: 6.* php: 8.3 + - laravel: 6.* + php: 8.4 - laravel: 7.* php: 7.1 - laravel: 7.* @@ -63,6 +69,8 @@ jobs: php: 8.2 - laravel: 7.* php: 8.3 + - laravel: 7.* + php: 8.4 - laravel: 8.* php: 7.1 - laravel: 8.* @@ -71,6 +79,8 @@ jobs: php: 8.2 - laravel: 8.* php: 8.3 + - laravel: 8.* + php: 8.4 - laravel: 9.* php: 7.1 - laravel: 9.* @@ -79,6 +89,8 @@ jobs: php: 7.3 - laravel: 9.* php: 7.4 + - laravel: 9.* + php: 8.4 - laravel: 10.* php: 7.1 - laravel: 10.* @@ -89,6 +101,8 @@ jobs: php: 7.4 - laravel: 10.* php: '8.0' + - laravel: 10.* + php: 8.4 - laravel: 11.* php: 7.1 - laravel: 11.* @@ -101,6 +115,18 @@ jobs: php: '8.0' - laravel: 11.* php: '8.1' + - laravel: 12.* + php: 7.1 + - laravel: 12.* + php: 7.2 + - laravel: 12.* + php: 7.3 + - laravel: 12.* + php: 7.4 + - laravel: 12.* + php: '8.0' + - laravel: 12.* + php: '8.1' name: PHP ${{ matrix.php }} / Laravel ${{ matrix.laravel }} @@ -115,11 +141,14 @@ jobs: extension: mbstring, pdo, pdo_sqlite coverage: none - - name: Install dependencies + - name: Require DBAL run: | - composer require "illuminate/contracts:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update composer require "doctrine/dbal:${{ matrix.dbal }}" --dev --no-interaction --no-update - composer install --prefer-dist --no-interaction --no-suggest + if: matrix.dbal + + - name: Install dependencies + run: | + composer update --prefer-dist --no-interaction --no-suggest --with="orchestra/testbench:${{ matrix.testbench }}" --with="illuminate/support:${{ matrix.laravel }}" - name: Installed dependencies run: composer show -D diff --git a/composer.json b/composer.json index 2e0bc31..2bb2d82 100644 --- a/composer.json +++ b/composer.json @@ -12,13 +12,13 @@ "php": "^7.1.3|^8.0", "ext-pdo_sqlite": "*", "ext-sqlite3": "*", - "illuminate/database": "^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0", - "illuminate/support": "^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0" + "illuminate/database": "^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0", + "illuminate/support": "^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0" }, "require-dev": { "doctrine/dbal": "^2.9 || ^3.1.4", - "orchestra/testbench": "3.8.* || 3.9.* || ^4.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0", - "phpunit/phpunit": "^7.5 || ^8.4 || ^9.0 || ^10.0" + "orchestra/testbench": "3.8.* || 3.9.* || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0", + "phpunit/phpunit": "^7.5 || ^8.4 || ^9.0 || ^10.0 || ^11.0" }, "autoload": { "psr-4": { diff --git a/tests/SushiTest.php b/tests/SushiTest.php index d719df2..d252838 100644 --- a/tests/SushiTest.php +++ b/tests/SushiTest.php @@ -9,6 +9,8 @@ use Illuminate\Support\Facades\Validator; use Orchestra\Testbench\TestCase; +use function Orchestra\Testbench\laravel_version_compare; + class SushiTest extends TestCase { public $cachePath; @@ -56,7 +58,10 @@ function columns_with_varying_types() $this->assertEquals('integer', $connectionBuilder->getColumnType('model_with_varying_type_columns', 'int')); $this->assertEquals('float', $connectionBuilder->getColumnType('model_with_varying_type_columns', 'float')); $this->assertEquals('datetime', $connectionBuilder->getColumnType('model_with_varying_type_columns', 'dateTime')); - $this->assertEquals('string', $connectionBuilder->getColumnType('model_with_varying_type_columns', 'string')); + $this->assertEquals( + function_exists('\Orchestra\Testbench\laravel_version_compare') && laravel_version_compare('11.0.0', '>=') ? 'varchar' : 'string', + $connectionBuilder->getColumnType('model_with_varying_type_columns', 'string') + ); $this->assertEquals(null, $row->null); } @@ -65,8 +70,14 @@ function model_with_custom_schema() { ModelWithCustomSchema::count(); $connectionBuilder = ModelWithCustomSchema::resolveConnection()->getSchemaBuilder(); - $this->assertEquals('string', $connectionBuilder->getColumnType('model_with_custom_schemas', 'float')); - $this->assertEquals('string', $connectionBuilder->getColumnType('model_with_custom_schemas', 'string')); + $this->assertEquals( + function_exists('\Orchestra\Testbench\laravel_version_compare') && laravel_version_compare('11.0.0', '>=') ? 'varchar' : 'string', + $connectionBuilder->getColumnType('model_with_custom_schemas', 'float') + ); + $this->assertEquals( + function_exists('\Orchestra\Testbench\laravel_version_compare') && laravel_version_compare('11.0.0', '>=') ? 'varchar' : 'string', + $connectionBuilder->getColumnType('model_with_custom_schemas', 'string') + ); } /** @test */ @@ -187,6 +198,10 @@ public function it_runs_method_after_migration_when_defined() * */ function sushi_models_can_relate_to_models_in_regular_sqlite_databases() { + if (! trait_exists('\Orchestra\Testbench\Concerns\HandlesAnnotations')) { + $this->markTestSkipped('Requires HandlesAnnotation trait to define sqlite connection using PHPUnit annotation'); + } + $this->loadMigrationsFrom(__DIR__ . '/database/migrations'); $this->artisan('migrate', ['--database' => 'testbench-sqlite'])->run();