From c55d1b8371d440d224f2d63f04f1f58c06f17802 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 23 Feb 2024 10:15:17 +0000 Subject: [PATCH 01/15] Change how we call the Antlers parser --- src/Console/Commands/RebuildUriCache.php | 4 ++-- src/Routing/Traits/RunwayRoutes.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Console/Commands/RebuildUriCache.php b/src/Console/Commands/RebuildUriCache.php index c4bbbed3..69ab675c 100644 --- a/src/Console/Commands/RebuildUriCache.php +++ b/src/Console/Commands/RebuildUriCache.php @@ -5,7 +5,7 @@ use Illuminate\Console\Command; use Illuminate\Support\Str; use Statamic\Console\RunsInPlease; -use Statamic\View\Antlers\Parser; +use Statamic\Facades\Antlers; use StatamicRadPack\Runway\Resource; use StatamicRadPack\Runway\Routing\RunwayUri; use StatamicRadPack\Runway\Runway; @@ -67,7 +67,7 @@ public function handle() } $this->withProgressBar($resource->model()->all(), function ($model) use ($resource) { - $uri = (new Parser()) + $uri = Antlers::parser() ->parse($resource->route(), $model->toAugmentedArray()) ->__toString(); diff --git a/src/Routing/Traits/RunwayRoutes.php b/src/Routing/Traits/RunwayRoutes.php index 90154410..4f4ab17b 100644 --- a/src/Routing/Traits/RunwayRoutes.php +++ b/src/Routing/Traits/RunwayRoutes.php @@ -4,9 +4,9 @@ use Illuminate\Database\Eloquent\Relations\MorphOne; use Illuminate\Support\Str; +use Statamic\Facades\Antlers; use Statamic\StaticCaching\Cacher; use Statamic\Support\Arr; -use Statamic\View\Antlers\Parser; use StatamicRadPack\Runway\Routing\Routable; use StatamicRadPack\Runway\Routing\RoutingModel; use StatamicRadPack\Runway\Routing\RunwayUri; @@ -80,7 +80,7 @@ public static function bootRunwayRoutes() return; } - $uri = (new Parser()) + $uri = Antlers::parser() ->parse($resource->route(), $model->toAugmentedArray()) ->__toString(); From c560688e42252b54d413a32e51bbf852713c75af Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Sat, 24 Feb 2024 23:25:03 +0000 Subject: [PATCH 02/15] Simplify the `TestCase` Made possible because of statamic/cms#9573. --- tests/TestCase.php | 62 +++------------------------------------------- 1 file changed, 4 insertions(+), 58 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index b002358e..37ee7610 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,62 +4,26 @@ use Illuminate\Encryption\Encrypter; use Illuminate\Foundation\Testing\RefreshDatabase; -use Orchestra\Testbench\TestCase as OrchestraTestCase; -use Rebing\GraphQL\GraphQLServiceProvider; -use Statamic\Extend\Manifest; +use Statamic\Extend\AddonTestCase; use Statamic\Facades\Blueprint; -use Statamic\Providers\StatamicServiceProvider; use Statamic\Stache\Stores\UsersStore; use Statamic\Statamic; use StatamicRadPack\Runway\ServiceProvider; -abstract class TestCase extends OrchestraTestCase +abstract class TestCase extends AddonTestCase { use RefreshDatabase; + protected string $addonServiceProvider = ServiceProvider::class; + protected $shouldFakeVersion = true; protected function setUp(): void { parent::setUp(); - $this->withoutVite(); - $this->runLaravelMigrations(); $this->loadMigrationsFrom(__DIR__.'/__fixtures__/database/migrations'); - - if ($this->shouldFakeVersion) { - \Facades\Statamic\Version::shouldReceive('get')->andReturn('4.0.0-testing'); - $this->addToAssertionCount(-1); // Dont want to assert this - } - } - - protected function getPackageProviders($app) - { - return [ - GraphQLServiceProvider::class, - StatamicServiceProvider::class, - ServiceProvider::class, - ]; - } - - protected function getPackageAliases($app) - { - return [ - 'Statamic' => Statamic::class, - ]; - } - - protected function getEnvironmentSetUp($app) - { - parent::getEnvironmentSetUp($app); - - $app->make(Manifest::class)->manifest = [ - 'statamic-rad-pack/runway' => [ - 'id' => 'statamic-rad-pack/runway', - 'namespace' => 'StatamicRadPack\\Runway', - ], - ]; } protected function resolveApplicationConfiguration($app) @@ -74,24 +38,6 @@ protected function resolveApplicationConfiguration($app) __DIR__.'/__fixtures__/resources/views', ]); - $configs = [ - 'assets', - 'cp', - 'forms', - 'static_caching', - 'sites', - 'stache', - 'system', - 'users', - ]; - - foreach ($configs as $config) { - $app['config']->set( - "statamic.$config", - require (__DIR__."/../vendor/statamic/cms/config/{$config}.php") - ); - } - $app['config']->set('statamic.api.enabled', true); $app['config']->set('statamic.editions.pro', true); $app['config']->set('statamic.users.repository', 'file'); From 2c549df1a3dad792644b68d41cf9076693bf390b Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 15 Mar 2024 11:55:56 +0000 Subject: [PATCH 03/15] Tweak version in `composer.json` --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 35316050..c13174b7 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "php": "^8.1", "doctrine/dbal": "^3.7", "pixelfear/composer-dist-plugin": "^0.1.5", - "statamic/cms": "^4.44" + "statamic/cms": "dev-master" }, "require-dev": { "laravel/pint": "^1.0", From f509b85b409f9e32b1afccc6ce567ca3c18147af Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 15 Mar 2024 11:58:00 +0000 Subject: [PATCH 04/15] tweak version in testing matrix too --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3eaa4ea0..9629e9c9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: matrix: php: [8.3, 8.2, 8.1] laravel: [10.*] - statamic: [^4.0] + statamic: [dev-master] testbench: [8.*] os: [ubuntu-latest] From bf98cf93b87e2e65a03e1b270c738419e73105b9 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 15 Mar 2024 12:28:56 +0000 Subject: [PATCH 05/15] Update orchestra/testbench --- .github/workflows/tests.yml | 6 +++--- composer.json | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9629e9c9..2fafa131 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,10 +12,10 @@ jobs: strategy: matrix: - php: [8.3, 8.2, 8.1] - laravel: [10.*] + php: [8.3, 8.2] + laravel: [11.*] statamic: [dev-master] - testbench: [8.*] + testbench: [9.*] os: [ubuntu-latest] name: ${{ matrix.php }} - ${{ matrix.statamic }} - ${{ matrix.laravel }} diff --git a/composer.json b/composer.json index c13174b7..f4f3af4e 100644 --- a/composer.json +++ b/composer.json @@ -45,9 +45,8 @@ }, "require-dev": { "laravel/pint": "^1.0", - "nunomaduro/collision": "^6.1", "spatie/test-time": "^1.2", - "orchestra/testbench": "^8.0", + "orchestra/testbench": "^9.0", "phpunit/phpunit": "^10.0" }, "scripts": { From 4f866d533efbf2e69a694b00dfac456aadfcc613 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 15 Mar 2024 12:29:37 +0000 Subject: [PATCH 06/15] update system requirements in docs --- docs/installation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 600a9725..5d87fefc 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -4,9 +4,9 @@ title: 'Installation' ## System Requirements -- PHP 8.1 & above -- Statamic v4 -- Laravel 10 & above +- Statamic 5 +- Laravel 11 +- PHP 8.2 or above ## Installing via Composer From b02a674c04b8c6664d082eb302d60d9f5399cb32 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 15 Mar 2024 13:19:13 +0000 Subject: [PATCH 07/15] Casts are now defined in a method --- docs/blueprints.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/blueprints.md b/docs/blueprints.md index aa5baa10..7d2ea82b 100644 --- a/docs/blueprints.md +++ b/docs/blueprints.md @@ -72,9 +72,12 @@ $table->json('values')->nullable(); And the cast defined on the model: ```php -protected $casts = [ - 'values' => 'array', // or 'json', AsArrayObject::class -]; +protected function casts(): array +{ + return [ + 'values' => 'array', // or 'json', AsArrayObject::class + ]; +} ``` :::note Note! From c653e85a9c4a2577ed9a655905a60e74ba2aa62d Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 15 Mar 2024 14:11:21 +0000 Subject: [PATCH 08/15] Add notes about dropped support to upgrade guide --- docs/upgrade-guides/v6-x-to-v7-0.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/upgrade-guides/v6-x-to-v7-0.md b/docs/upgrade-guides/v6-x-to-v7-0.md index 6b7e6c5b..d30ff4e0 100644 --- a/docs/upgrade-guides/v6-x-to-v7-0.md +++ b/docs/upgrade-guides/v6-x-to-v7-0.md @@ -35,7 +35,21 @@ php artisan view:clear ## Changes -TODO +### High: Support for Statamic 4 has been dropped + +Runway v7 has dropped support for Statamic 4. In order to update Runway, you will need to [upgrade to Statamic 5](https://statamic.dev/upgrade-guide/4-0-to-5-0). + +By keeping up-to-date with major Statamic versions, it removes the risk of any compatibility issues between Statamic 4 and 5. + +### High: Support for Laravel 10 has been dropped + +Runway v7 has dropped support for Laravel 10. In order to update Runway, you will need to [upgrade to Laravel 11](https://laravel.com/docs/11.x/upgrade). + +If you wish, you can automate the upgrade process using [Laravel Shift](https://laravelshift.com/upgrade-laravel-10-to-laravel-11). + +### Medium: Support for PHP 8.1 has been dropped + +Runway v7 has dropped support for PHP 8.1. In order to update Runway, you should update the version of PHP you're using, both locally and on production. The latest version of PHP is 8.3. ## Previous upgrade guides From 9b0d06c10be4929fb4d303160a611386fb9f5f57 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Thu, 4 Apr 2024 21:24:10 +0100 Subject: [PATCH 09/15] Replace `str_slug` with `Str::slug` --- tests/__fixtures__/database/factories/PostFactory.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/__fixtures__/database/factories/PostFactory.php b/tests/__fixtures__/database/factories/PostFactory.php index b2fa614b..c0eb3927 100644 --- a/tests/__fixtures__/database/factories/PostFactory.php +++ b/tests/__fixtures__/database/factories/PostFactory.php @@ -3,6 +3,7 @@ namespace StatamicRadPack\Runway\Tests\Fixtures\Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; +use Illuminate\Support\Str; use StatamicRadPack\Runway\Tests\Fixtures\Models\Author; use StatamicRadPack\Runway\Tests\Fixtures\Models\Post; @@ -24,7 +25,7 @@ public function definition() { return [ 'title' => $title = implode(' ', $this->faker->words(6)), - 'slug' => str_slug($title), + 'slug' => Str::slug($title), 'body' => implode(' ', $this->faker->paragraphs(10)), 'author_id' => Author::factory()->create()->id, ]; From 33872d994308d545cc53ac675ab512f46700bc7e Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Sat, 6 Apr 2024 18:56:58 +0100 Subject: [PATCH 10/15] Improve UX of commands --- composer.json | 1 + src/Console/Commands/GenerateBlueprint.php | 8 ++--- src/Console/Commands/GenerateMigration.php | 6 ++-- src/Console/Commands/ListResources.php | 2 +- src/Console/Commands/RebuildUriCache.php | 36 ++++++++++++---------- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index f4f3af4e..7be92b40 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ "require": { "php": "^8.1", "doctrine/dbal": "^3.7", + "laravel/prompts": "^0.1.17", "pixelfear/composer-dist-plugin": "^0.1.5", "statamic/cms": "dev-master" }, diff --git a/src/Console/Commands/GenerateBlueprint.php b/src/Console/Commands/GenerateBlueprint.php index 7c0fa68a..d6f36659 100644 --- a/src/Console/Commands/GenerateBlueprint.php +++ b/src/Console/Commands/GenerateBlueprint.php @@ -124,7 +124,7 @@ public function __construct() */ public function handle() { - $this->info('Generating blueprints...'); + $this->components->info('Generating blueprints...'); $this->line(''); $resources = []; @@ -143,7 +143,7 @@ public function handle() $this->generateForResource($resource); } - $this->info('✔️ Done'); + $this->components->info('✔️ Done'); } protected function generateForResource(Resource $resource) @@ -171,13 +171,13 @@ protected function generateForResource(Resource $resource) $this->generateNewBlueprint($resource, $fields); if (count($errorMessages) === 0) { - $this->line("✔️ {$resource->name()}"); + $this->components->info("✔️ {$resource->name()}"); $this->line(''); } else { $this->line("❌ {$resource->name()}"); foreach ($errorMessages as $errorMessage) { - $this->comment($errorMessage); + $this->components->comment($errorMessage); } $this->line(''); diff --git a/src/Console/Commands/GenerateMigration.php b/src/Console/Commands/GenerateMigration.php index 16d7e8c7..868434bc 100644 --- a/src/Console/Commands/GenerateMigration.php +++ b/src/Console/Commands/GenerateMigration.php @@ -13,6 +13,8 @@ use StatamicRadPack\Runway\Runway; use Symfony\Component\Process\Process; +use function Laravel\Prompts\confirm; + class GenerateMigration extends Command { use RunsInPlease; @@ -181,7 +183,7 @@ public function __construct() */ public function handle() { - $this->info('Generating migrations...'); + $this->components->info('Generating migrations...'); $this->line(''); $resources = []; @@ -201,7 +203,7 @@ public function handle() $this->generateForResource($resource); } - if ($this->ask('Should we run your migrations?', 'yes') === 'yes') { + if (confirm('Should we run your migrations?', 'yes') === 'yes') { Artisan::call('migrate'); } diff --git a/src/Console/Commands/ListResources.php b/src/Console/Commands/ListResources.php index a90e36fc..eaf24d23 100644 --- a/src/Console/Commands/ListResources.php +++ b/src/Console/Commands/ListResources.php @@ -43,7 +43,7 @@ public function __construct() public function handle() { if (! Runway::allResources()->count()) { - return $this->error("Your application doesn't have any resources."); + return $this->components->error("Your application doesn't have any resources."); } $this->table( diff --git a/src/Console/Commands/RebuildUriCache.php b/src/Console/Commands/RebuildUriCache.php index c1c1f1bd..009e1b93 100644 --- a/src/Console/Commands/RebuildUriCache.php +++ b/src/Console/Commands/RebuildUriCache.php @@ -10,6 +10,9 @@ use StatamicRadPack\Runway\Routing\RunwayUri; use StatamicRadPack\Runway\Runway; +use function Laravel\Prompts\confirm; +use function Laravel\Prompts\progress; + class RebuildUriCache extends Command { use RunsInPlease; @@ -47,7 +50,7 @@ public function __construct() public function handle() { if (! $this->option('force')) { - $confirm = $this->confirm( + $confirm = confirm( 'You are about to rebuild your entire URI cache. This may take part of your site down while running. Are you sure you want to continue?' ); @@ -60,11 +63,8 @@ public function handle() Runway::allResources() ->each(function (Resource $resource) { - $this->newLine(2); - $this->info("Building {$resource->name()} URIs"); - if (! $resource->hasRouting()) { - $this->warn("Skipping {$resource->name()}, routing not configured."); + $this->components->warn("Skipping {$resource->name()}, routing not configured."); return; } @@ -72,17 +72,21 @@ public function handle() $query = $resource->model()->newQuery(); $query->when($query->hasNamedScope('runwayRoutes'), fn ($query) => $query->runwayRoutes()); - $this->withProgressBar($query->get(), function ($model) use ($resource) { - $uri = Antlers::parser() - ->parse($resource->route(), $model->toAugmentedArray()) - ->__toString(); - - $uri = Str::start($uri, '/'); - - $model->runwayUri()->create([ - 'uri' => $uri, - ]); - }); + progress( + label: "Caching {$resource->name()} URIs", + steps: $query->get(), + callback: function ($model) use ($resource) { + $uri = Antlers::parser() + ->parse($resource->route(), $model->toAugmentedArray()) + ->__toString(); + + $uri = Str::start($uri, '/'); + + $model->runwayUri()->create([ + 'uri' => $uri, + ]); + } + ); }); } } From bac17572b012a747d945c10cb2737863bceafa7e Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Sat, 6 Apr 2024 22:45:51 +0100 Subject: [PATCH 11/15] Fix failing tests after improving console UX --- composer.json | 1 + src/Console/Commands/GenerateBlueprint.php | 2 +- src/Console/Commands/GenerateMigration.php | 2 +- src/Console/Commands/RebuildUriCache.php | 6 ++++++ tests/Console/Commands/GenerateBlueprintTest.php | 10 +++++----- tests/Console/Commands/GenerateMigrationTest.php | 16 ++++++++-------- tests/Console/Commands/ListResourcesTest.php | 2 +- tests/Console/Commands/RebuildUriCacheTest.php | 2 +- 8 files changed, 24 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index 7be92b40..e3cd4092 100644 --- a/composer.json +++ b/composer.json @@ -41,6 +41,7 @@ "php": "^8.1", "doctrine/dbal": "^3.7", "laravel/prompts": "^0.1.17", + "laravel/framework": "^10.25.0 || ^11.0", "pixelfear/composer-dist-plugin": "^0.1.5", "statamic/cms": "dev-master" }, diff --git a/src/Console/Commands/GenerateBlueprint.php b/src/Console/Commands/GenerateBlueprint.php index d6f36659..0bb60a91 100644 --- a/src/Console/Commands/GenerateBlueprint.php +++ b/src/Console/Commands/GenerateBlueprint.php @@ -177,7 +177,7 @@ protected function generateForResource(Resource $resource) $this->line("❌ {$resource->name()}"); foreach ($errorMessages as $errorMessage) { - $this->components->comment($errorMessage); + $this->components->error($errorMessage); } $this->line(''); diff --git a/src/Console/Commands/GenerateMigration.php b/src/Console/Commands/GenerateMigration.php index 868434bc..f69f45e1 100644 --- a/src/Console/Commands/GenerateMigration.php +++ b/src/Console/Commands/GenerateMigration.php @@ -203,7 +203,7 @@ public function handle() $this->generateForResource($resource); } - if (confirm('Should we run your migrations?', 'yes') === 'yes') { + if (confirm('Should we run your migrations?')) { Artisan::call('migrate'); } diff --git a/src/Console/Commands/RebuildUriCache.php b/src/Console/Commands/RebuildUriCache.php index 009e1b93..72b38a27 100644 --- a/src/Console/Commands/RebuildUriCache.php +++ b/src/Console/Commands/RebuildUriCache.php @@ -72,6 +72,12 @@ public function handle() $query = $resource->model()->newQuery(); $query->when($query->hasNamedScope('runwayRoutes'), fn ($query) => $query->runwayRoutes()); + if (! $query->exists()) { + $this->components->warn("Skipping {$resource->name()}, no models to cache."); + + return; + } + progress( label: "Caching {$resource->name()} URIs", steps: $query->get(), diff --git a/tests/Console/Commands/GenerateBlueprintTest.php b/tests/Console/Commands/GenerateBlueprintTest.php index acf6b91f..c9154b46 100644 --- a/tests/Console/Commands/GenerateBlueprintTest.php +++ b/tests/Console/Commands/GenerateBlueprintTest.php @@ -100,8 +100,8 @@ public function can_generate_blueprint() ->once(); $this->artisan('runway:generate-blueprints', ['resource' => 'post']) - ->expectsOutput('Generating blueprints...') - ->expectsOutput('✔️ Done') + ->expectsOutputToContain('Generating blueprints...') + ->expectsOutputToContain('✔️ Done') ->assertExitCode(0); } @@ -149,10 +149,10 @@ public function can_generate_resource_with_column_that_can_not_be_matched_to_a_f ->once(); $this->artisan('runway:generate-blueprints', ['resource' => 'post']) - ->expectsOutput('Generating blueprints...') + ->expectsOutputToContain('Generating blueprints...') ->expectsOutput('❌ Posts') - ->expectsOutput('Column [blob] could not be matched with a fieldtype.') - ->expectsOutput('✔️ Done') + ->expectsOutputToContain('Column [blob] could not be matched with a fieldtype.') + ->expectsOutputToContain('✔️ Done') ->assertExitCode(0); } } diff --git a/tests/Console/Commands/GenerateMigrationTest.php b/tests/Console/Commands/GenerateMigrationTest.php index 4956d96f..830b946a 100644 --- a/tests/Console/Commands/GenerateMigrationTest.php +++ b/tests/Console/Commands/GenerateMigrationTest.php @@ -70,7 +70,7 @@ public function can_generate_migrations_for_multiple_resources() $this ->artisan('runway:generate-migrations') - ->expectsQuestion('Should we run your migrations?', 'no') + ->expectsQuestion('Should we run your migrations?', false) ->execute(); $this->assertFileExists( @@ -122,7 +122,7 @@ public function can_generate_migration_for_single_resource() ->artisan('runway:generate-migrations', [ 'resource' => 'food', ]) - ->expectsQuestion('Should we run your migrations?', 'no') + ->expectsQuestion('Should we run your migrations?', false) ->execute(); $this->assertFileExists( @@ -163,7 +163,7 @@ public function cant_generate_migration_where_table_already_exists() ->artisan('runway:generate-migrations', [ 'resource' => 'food', ]) - ->expectsQuestion('Should we run your migrations?', 'no') + ->expectsQuestion('Should we run your migrations?', false) ->expectsOutput('Table [foods] already exists. Runway is not smart enough yet to update existing migrations. Sorry!') ->execute(); @@ -193,7 +193,7 @@ public function can_generate_migration_and_run_them_afterwards() ->artisan('runway:generate-migrations', [ 'resource' => 'food', ]) - ->expectsQuestion('Should we run your migrations?', 'yes') + ->expectsQuestion('Should we run your migrations?', true) ->execute(); $this->assertFileExists(database_path().'/migrations/'.now()->format('Y_m_d_His').'_create_foods_table.php'); @@ -226,7 +226,7 @@ public function can_generate_migration_and_ensure_normal_field_is_correct() ->artisan('runway:generate-migrations', [ 'resource' => 'food', ]) - ->expectsQuestion('Should we run your migrations?', 'no') + ->expectsQuestion('Should we run your migrations?', false) ->execute(); $this->assertFileExists( @@ -275,7 +275,7 @@ public function can_generate_migration_and_ensure_max_items_1_field_is_correct() ->artisan('runway:generate-migrations', [ 'resource' => 'food', ]) - ->expectsQuestion('Should we run your migrations?', 'no') + ->expectsQuestion('Should we run your migrations?', false) ->execute(); $this->assertFileExists( @@ -320,7 +320,7 @@ public function can_generate_migration_and_ensure_field_is_nullable_if_required_ ->artisan('runway:generate-migrations', [ 'resource' => 'food', ]) - ->expectsQuestion('Should we run your migrations?', 'no') + ->expectsQuestion('Should we run your migrations?', false) ->execute(); $this->assertFileExists( @@ -355,7 +355,7 @@ public function can_generate_migration_and_ensure_field_is_not_nullable_if_requi ->artisan('runway:generate-migrations', [ 'resource' => 'food', ]) - ->expectsQuestion('Should we run your migrations?', 'no') + ->expectsQuestion('Should we run your migrations?', false) ->execute(); $this->assertFileExists( diff --git a/tests/Console/Commands/ListResourcesTest.php b/tests/Console/Commands/ListResourcesTest.php index 18ee12af..80ac723b 100644 --- a/tests/Console/Commands/ListResourcesTest.php +++ b/tests/Console/Commands/ListResourcesTest.php @@ -32,6 +32,6 @@ public function it_outputs_error_when_no_resources_exist() $this ->artisan('runway:resources') - ->expectsOutput("Your application doesn't have any resources."); + ->expectsOutputToContain("Your application doesn't have any resources."); } } diff --git a/tests/Console/Commands/RebuildUriCacheTest.php b/tests/Console/Commands/RebuildUriCacheTest.php index 7b2f7886..6bbdc45d 100644 --- a/tests/Console/Commands/RebuildUriCacheTest.php +++ b/tests/Console/Commands/RebuildUriCacheTest.php @@ -67,7 +67,7 @@ public function skips_resources_without_routing_configured() 'You are about to rebuild your entire URI cache. This may take part of your site down while running. Are you sure you want to continue?', 'yes' ) - ->expectsOutput('Skipping Author, routing not configured.'); + ->expectsOutputToContain('Skipping Author, routing not configured.'); $this->assertCount(0, RunwayUri::all()); } From 0ba0a5ae8424cf4e327ea09d8e5bda786ea19088 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Sat, 6 Apr 2024 22:52:45 +0100 Subject: [PATCH 12/15] Adopt new `casts` method --- tests/__fixtures__/app/Models/Post.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/__fixtures__/app/Models/Post.php b/tests/__fixtures__/app/Models/Post.php index c1ebadd5..b1f0e62f 100644 --- a/tests/__fixtures__/app/Models/Post.php +++ b/tests/__fixtures__/app/Models/Post.php @@ -23,10 +23,13 @@ class Post extends Model 'excerpt', ]; - protected $casts = [ - 'values' => 'array', - 'external_links' => 'object', - ]; + public function casts(): array + { + return [ + 'values' => 'array', + 'external_links' => 'object', + ]; + } public function scopeFood($query) { From 6998ea3b65373f3e3f318ee8f5c9fcf213fe44be Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Tue, 9 Apr 2024 19:52:34 +0100 Subject: [PATCH 13/15] Use the real 5.0 version constraint --- .github/workflows/tests.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2fafa131..23f59888 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: matrix: php: [8.3, 8.2] laravel: [11.*] - statamic: [dev-master] + statamic: [^5.0] testbench: [9.*] os: [ubuntu-latest] diff --git a/composer.json b/composer.json index e3cd4092..0d56b9ce 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "laravel/prompts": "^0.1.17", "laravel/framework": "^10.25.0 || ^11.0", "pixelfear/composer-dist-plugin": "^0.1.5", - "statamic/cms": "dev-master" + "statamic/cms": "^5.0" }, "require-dev": { "laravel/pint": "^1.0", From 3a9b4e766818ea0e28fe07664a8b3769c79c0246 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Tue, 9 Apr 2024 19:54:32 +0100 Subject: [PATCH 14/15] Tweak Orchestra Testbench versions & drop test script from `composer.json` --- .github/workflows/tests.yml | 5 ++--- composer.json | 9 ++------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 23f59888..ea065749 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,6 @@ jobs: php: [8.3, 8.2] laravel: [11.*] statamic: [^5.0] - testbench: [9.*] os: [ubuntu-latest] name: ${{ matrix.php }} - ${{ matrix.statamic }} - ${{ matrix.laravel }} @@ -32,8 +31,8 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "statamic/cms:${{ matrix.statamic }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "statamic/cms:${{ matrix.statamic }}" --no-interaction --no-update composer install --no-interaction - name: Run PHPUnit - run: composer test + run: vendor/bin/phpunit diff --git a/composer.json b/composer.json index 0d56b9ce..af4b60e3 100644 --- a/composer.json +++ b/composer.json @@ -48,13 +48,8 @@ "require-dev": { "laravel/pint": "^1.0", "spatie/test-time": "^1.2", - "orchestra/testbench": "^9.0", - "phpunit/phpunit": "^10.0" - }, - "scripts": { - "test": [ - "php -d memory_limit=-1 ./vendor/bin/phpunit" - ] + "orchestra/testbench": "^8.0 || ^9.0", + "phpunit/phpunit": "^10.0", }, "config": { "optimize-autoloader": true, From 791cfc4b246cdc51687b7d804fb013f239c044e3 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Tue, 9 Apr 2024 19:55:26 +0100 Subject: [PATCH 15/15] whoopsie, fix invalid json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index af4b60e3..ba4d6825 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "laravel/pint": "^1.0", "spatie/test-time": "^1.2", "orchestra/testbench": "^8.0 || ^9.0", - "phpunit/phpunit": "^10.0", + "phpunit/phpunit": "^10.0" }, "config": { "optimize-autoloader": true,