From ad4c683e39122cd6cd7d9b5d4d891777ca14d2f2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Mar 2026 12:52:26 +0000 Subject: [PATCH 1/4] Initial plan From 312235971b4b99f2be4154f13501e1e7efad9577 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Mar 2026 13:03:40 +0000 Subject: [PATCH 2/4] Fix failing tests for PHPUnit 12 / Laravel 13 compatibility Co-authored-by: chinleung <19669331+chinleung@users.noreply.github.com> --- composer.json | 6 ++-- phpunit.xml.dist | 13 +++----- tests/RedirectTest.php | 3 +- tests/RequestTest.php | 3 +- tests/ResourceTest.php | 35 ++++++++++---------- tests/RouteTest.php | 75 +++++++++++++++++++++--------------------- tests/UrlTest.php | 5 +-- 7 files changed, 70 insertions(+), 70 deletions(-) diff --git a/composer.json b/composer.json index 81036a9..6ed7535 100644 --- a/composer.json +++ b/composer.json @@ -21,11 +21,11 @@ "require": { "php": "^8.2", "chinleung/laravel-locales": "^2.0", - "illuminate/support": "^12.0" + "illuminate/support": "^12.0|^13.0" }, "require-dev": { - "orchestra/testbench": "^8.0|^9.0|^10.0", - "phpunit/phpunit": "^9.5.10|^10.5|^11.5.3" + "orchestra/testbench": "^8.0|^9.0|^10.0|^11.0", + "phpunit/phpunit": "^9.5.10|^10.5|^11.5.3|^12.5.12" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f2eebe0..eef321c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,7 @@ @@ -14,9 +9,9 @@ tests - - + + src/ - - + + diff --git a/tests/RedirectTest.php b/tests/RedirectTest.php index 92d91b1..19b972f 100644 --- a/tests/RedirectTest.php +++ b/tests/RedirectTest.php @@ -6,10 +6,11 @@ use ChinLeung\MultilingualRoutes\MultilingualRoutesServiceProvider; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; class RedirectTest extends TestCase { - /** @test **/ + #[Test] public function a_localized_redirect_can_be_made(): void { Route::multilingual('start', function () { diff --git a/tests/RequestTest.php b/tests/RequestTest.php index 49986fd..8fedf4a 100644 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -7,10 +7,11 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; class RequestTest extends TestCase { - /** @test **/ + #[Test] public function a_request_name_can_be_matched(): void { Route::multilingual('test'); diff --git a/tests/ResourceTest.php b/tests/ResourceTest.php index 0e63dbe..4b47e0c 100644 --- a/tests/ResourceTest.php +++ b/tests/ResourceTest.php @@ -6,6 +6,7 @@ use ChinLeung\MultilingualRoutes\MultilingualRoutesServiceProvider; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; class ResourceTest extends TestCase { @@ -18,7 +19,7 @@ protected function setUp(): void ]]); } - /** @test **/ + #[Test] public function a_multilingual_resource_route_can_be_registered(): void { $this->registerTestTranslations(); @@ -50,7 +51,7 @@ public function a_multilingual_resource_route_can_be_registered(): void } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_use_translated_uris(): void { $this->registerTestTranslations(); @@ -66,7 +67,7 @@ public function a_multilingual_resource_can_use_translated_uris(): void $this->assertStringContainsString('fr/photos', $frIndexRoute->uri); } - /** @test **/ + #[Test] public function a_multilingual_resource_can_be_limited_to_specific_actions(): void { Route::multilingualResource('photos', 'PhotoController')->only(['index', 'show']); @@ -85,7 +86,7 @@ public function a_multilingual_resource_can_be_limited_to_specific_actions(): vo } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_exclude_specific_actions(): void { Route::multilingualResource('photos', 'PhotoController')->except(['create', 'edit']); @@ -104,7 +105,7 @@ public function a_multilingual_resource_can_exclude_specific_actions(): void } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_have_custom_parameter_names(): void { Route::multilingualResource('photos', 'PhotoController')->parameters([ @@ -126,7 +127,7 @@ public function a_multilingual_resource_can_have_custom_parameter_names(): void } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_be_limited_to_specific_locales(): void { Route::multilingualResource('photos', 'PhotoController')->onlyLocales(['fr']); @@ -136,7 +137,7 @@ public function a_multilingual_resource_can_be_limited_to_specific_locales(): vo $this->assertFalse(Route::has('en.photos.index')); } - /** @test **/ + #[Test] public function multilingual_resource_generates_correct_route_uris(): void { $this->registerTestTranslations(); @@ -185,7 +186,7 @@ protected function registerTranslations(array $translations): self return $this; } - /** @test **/ + #[Test] public function a_multilingual_resource_can_use_name_method(): void { Route::multilingualResource('photos', 'PhotoController')->name('gallery'); @@ -200,7 +201,7 @@ public function a_multilingual_resource_can_use_name_method(): void } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_use_middleware(): void { Route::multilingualResource('photos', 'PhotoController')->middleware('auth'); @@ -211,7 +212,7 @@ public function a_multilingual_resource_can_use_middleware(): void } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_use_where_constraints(): void { Route::multilingualResource('photos', 'PhotoController')->where('photos', '[0-9]+'); @@ -222,7 +223,7 @@ public function a_multilingual_resource_can_use_where_constraints(): void } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_use_defaults(): void { Route::multilingualResource('photos', 'PhotoController')->defaults(['format' => 'json']); @@ -233,7 +234,7 @@ public function a_multilingual_resource_can_use_defaults(): void } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_exclude_locales(): void { Route::multilingualResource('photos', 'PhotoController')->exceptLocales(['en']); @@ -243,7 +244,7 @@ public function a_multilingual_resource_can_exclude_locales(): void $this->assertFalse(Route::has('en.photos.index')); } - /** @test **/ + #[Test] public function a_multilingual_resource_can_use_names_array(): void { Route::multilingualResource('photos', 'PhotoController')->names([ @@ -259,7 +260,7 @@ public function a_multilingual_resource_can_use_names_array(): void $this->assertFalse(Route::has('fr.photos.index')); } - /** @test **/ + #[Test] public function a_multilingual_resource_can_use_missing_callback(): void { $callbackExecuted = false; @@ -277,7 +278,7 @@ public function a_multilingual_resource_can_use_missing_callback(): void } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_use_with_trashed(): void { Route::multilingualResource('photos', 'PhotoController')->withTrashed(['show', 'edit']); @@ -296,7 +297,7 @@ public function a_multilingual_resource_can_use_with_trashed(): void } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_use_where_param(): void { Route::multilingualResource('photos', 'PhotoController')->whereParam('photos', '[0-9]+'); @@ -307,7 +308,7 @@ public function a_multilingual_resource_can_use_where_param(): void } } - /** @test **/ + #[Test] public function a_multilingual_resource_can_chain_multiple_methods(): void { Route::multilingualResource('photos', 'PhotoController') diff --git a/tests/RouteTest.php b/tests/RouteTest.php index 13672cd..63069ce 100644 --- a/tests/RouteTest.php +++ b/tests/RouteTest.php @@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Route; use InvalidArgumentException; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class RouteTest extends TestCase @@ -24,7 +25,7 @@ protected function setUp(): void ]]); } - /** @test **/ + #[Test] public function a_multilingual_route_can_be_registered(): void { $this->registerTestRoute(); @@ -37,7 +38,7 @@ public function a_multilingual_route_can_be_registered(): void } } - /** @test **/ + #[Test] public function a_multilingual_redirect_route_can_be_registered(): void { $this->registerTestRedirectToRoute(); @@ -50,7 +51,7 @@ public function a_multilingual_redirect_route_can_be_registered(): void } } - /** @test **/ + #[Test] public function a_route_can_have_different_names_based_on_locales(): void { $this @@ -71,7 +72,7 @@ public function a_route_can_have_different_names_based_on_locales(): void ); } - /** @test **/ + #[Test] public function the_group_name_can_be_renamed(): void { $this @@ -86,7 +87,7 @@ public function the_group_name_can_be_renamed(): void } } - /** @test **/ + #[Test] public function the_locale_name_has_priority_over_group_name(): void { $this @@ -110,7 +111,7 @@ public function the_locale_name_has_priority_over_group_name(): void localized_route('foo', [], 'fr'); } - /** @test **/ + #[Test] public function it_can_limit_route_to_specific_locales(): void { $this->registerTestRoute() @@ -125,7 +126,7 @@ public function it_can_limit_route_to_specific_locales(): void localized_route('test', [], 'en'); } - /** @test **/ + #[Test] public function it_can_remove_specific_locales_from_route(): void { $this->registerTestRoute() @@ -140,7 +141,7 @@ public function it_can_remove_specific_locales_from_route(): void localized_route('test', [], 'fr'); } - /** @test **/ + #[Test] public function the_default_locale_routes_can_be_prefixed(): void { config([ @@ -156,7 +157,7 @@ public function the_default_locale_routes_can_be_prefixed(): void $this->assertEquals(url('fr/teste'), $route); } - /** @test **/ + #[Test] public function it_can_register_a_post_route(): void { $routes = $this @@ -165,7 +166,7 @@ public function it_can_register_a_post_route(): void ->register(); $routes = collect($routes)->reject(function ($route) { - return $route->getName() === 'storage.local'; + return str_starts_with($route->getName() ?? '', 'storage.local'); }); foreach ($routes as $route) { @@ -176,7 +177,7 @@ public function it_can_register_a_post_route(): void } } - /** @test **/ + #[Test] public function the_app_locale_will_be_used_in_case_of_wrong_locale(): void { $this->registerTestRoute(); @@ -187,7 +188,7 @@ public function the_app_locale_will_be_used_in_case_of_wrong_locale(): void ); } - /** @test **/ + #[Test] public function the_request_locale_can_be_changed_by_the_middleware(): void { $this->registerTestRoute(); @@ -205,7 +206,7 @@ function () { ); } - /** @test **/ + #[Test] public function the_home_page_can_be_registered(): void { Route::multilingual('/', static function () { @@ -216,7 +217,7 @@ public function the_home_page_can_be_registered(): void $this->assertEquals(url('fr'), localized_route('home', [], 'fr')); } - /** @test **/ + #[Test] public function a_route_without_handle_can_be_registered(): void { $this->registerTestTranslations(); @@ -227,7 +228,7 @@ public function a_route_without_handle_can_be_registered(): void $this->assertEquals(url('fr/teste'), localized_route('test', [], 'fr')); } - /** @test **/ + #[Test] public function a_route_with_identical_keys_can_be_registered(): void { Route::multilingual('test'); @@ -236,7 +237,7 @@ public function a_route_with_identical_keys_can_be_registered(): void $this->assertEquals(url('fr/test'), localized_route('test', [], 'fr')); } - /** @test **/ + #[Test] public function a_route_with_prefix_stack_can_be_registered(): void { $this->registerTestTranslations(); @@ -253,7 +254,7 @@ public function a_route_with_prefix_stack_can_be_registered(): void ); } - /** @test **/ + #[Test] public function a_root_route_with_prefix_stack_can_be_registered(): void { $this->registerTestTranslations(); @@ -270,7 +271,7 @@ public function a_root_route_with_prefix_stack_can_be_registered(): void ); } - /** @test **/ + #[Test] public function a_view_route_can_be_registered(): void { Route::multilingual('/')->view('app')->name('home'); @@ -279,7 +280,7 @@ public function a_view_route_can_be_registered(): void $this->assertEquals(url('fr'), localized_route('home', [], 'fr')); } - /** @test **/ + #[Test] public function a_view_route_can_be_registered_with_custom_data(): void { Route::multilingual('/')->name('home')->view('app', [ @@ -296,7 +297,7 @@ public function a_view_route_can_be_registered_with_custom_data(): void } } - /** @test **/ + #[Test] public function a_view_route_can_be_registered_with_custom_data_via_method(): void { Route::multilingual('/')->name('home')->view('app')->data([ @@ -313,7 +314,7 @@ public function a_view_route_can_be_registered_with_custom_data_via_method(): vo } } - /** @test **/ + #[Test] public function a_route_param_can_have_constraints(): void { $this->registerTranslations([ @@ -334,7 +335,7 @@ public function a_route_param_can_have_constraints(): void } } - /** @test **/ + #[Test] public function a_route_param_can_have_constraints_by_locale(): void { $this->registerTranslations([ @@ -359,7 +360,7 @@ public function a_route_param_can_have_constraints_by_locale(): void } } - /** @test **/ + #[Test] public function a_route_without_translation_will_be_registered_with_its_key(): void { Route::multilingual('test'); @@ -368,7 +369,7 @@ public function a_route_without_translation_will_be_registered_with_its_key(): v $this->assertEquals(url('fr/test'), localized_route('test', [], 'fr')); } - /** @test **/ + #[Test] public function a_starting_slash_will_be_trimmed_from_translation(): void { $this->registerTestTranslations(); @@ -381,7 +382,7 @@ public function a_starting_slash_will_be_trimmed_from_translation(): void $this->assertEquals(url('fr/teste'), localized_route('test', [], 'fr')); } - /** @test **/ + #[Test] public function the_current_route_can_be_retrieved_in_a_different_locale(): void { $this->registerTestRoute(); @@ -391,7 +392,7 @@ public function the_current_route_can_be_retrieved_in_a_different_locale(): void $this->assertEquals(localized_route('test', [], 'fr'), current_route('fr')); } - /** @test **/ + #[Test] public function the_current_route_can_be_retrieved_in_a_different_locale_with_query_strings(): void { $this->registerTestRoute(); @@ -410,7 +411,7 @@ public function the_current_route_can_be_retrieved_in_a_different_locale_with_qu ); } - /** @test **/ + #[Test] public function the_current_route_will_fallback_to_current_route_by_default(): void { Route::view('test', 'app'); @@ -424,7 +425,7 @@ public function the_current_route_will_fallback_to_current_route_by_default(): v $this->assertEquals(url('test'), current_route('fr')); } - /** @test **/ + #[Test] public function the_current_route_can_have_a_custom_fallback(): void { Route::view('test', 'app'); @@ -442,7 +443,7 @@ public function the_current_route_can_have_a_custom_fallback(): void ); } - /** @test **/ + #[Test] public function the_current_route_for_a_missing_page_will_return_the_custom_fallback(): void { Route::view('fallback', 'app'); @@ -461,7 +462,7 @@ public function the_current_route_for_a_missing_page_will_return_the_custom_fall } } - /** @test **/ + #[Test] public function a_route_prefix_can_be_registered_after_the_locale(): void { Route::name('prefix.')->group(static function () { @@ -472,7 +473,7 @@ public function a_route_prefix_can_be_registered_after_the_locale(): void $this->assertNotNull(localized_route('prefix.test', [], 'fr')); } - /** @test **/ + #[Test] public function a_route_prefix_can_be_registered_before_the_locale(): void { config([ @@ -487,7 +488,7 @@ public function a_route_prefix_can_be_registered_before_the_locale(): void $this->assertNotNull(route('prefix.fr.test')); } - /** @test **/ + #[Test] public function a_route_with_defaults_parameters_can_be_registered(): void { $params = ['param_1' => 'value_1', 'param_2' => 'value_2']; @@ -503,7 +504,7 @@ public function a_route_with_defaults_parameters_can_be_registered(): void } } - /** @test **/ + #[Test] public function the_default_home_page_can_be_registered_with_prefix(): void { config([ @@ -519,7 +520,7 @@ public function the_default_home_page_can_be_registered_with_prefix(): void $this->assertEquals(url('fr'), localized_route('home', [], 'fr')); } - /** @test **/ + #[Test] public function the_default_home_page_can_be_registered_without_prefix(): void { config([ @@ -535,13 +536,13 @@ public function the_default_home_page_can_be_registered_without_prefix(): void $this->assertEquals(url('fr'), localized_route('home', [], 'fr')); } - /** @test **/ + #[Test] public function a_route_can_be_registered_with_a_middleware(): void { Route::multilingual('/')->middleware('web'); $routes = collect(Route::getRoutes())->reject(function ($route) { - return $route->getName() === 'storage.local'; + return str_starts_with($route->getName() ?? '', 'storage.local'); }); foreach ($routes as $route) { @@ -549,7 +550,7 @@ public function a_route_can_be_registered_with_a_middleware(): void } } - /** @test **/ + #[Test] public function a_named_route_can_be_checked_if_it_exists(): void { $this diff --git a/tests/UrlTest.php b/tests/UrlTest.php index c644b6e..d36ce87 100644 --- a/tests/UrlTest.php +++ b/tests/UrlTest.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\URL; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; class UrlTest extends TestCase { @@ -18,7 +19,7 @@ protected function setUp(): void ]]); } - /** @test **/ + #[Test] public function a_multilingual_route_can_be_signed(): void { Route::multilingual('test'); @@ -29,7 +30,7 @@ public function a_multilingual_route_can_be_signed(): void $this->assertTrue(str_starts_with($request->url(), localized_route('test'))); } - /** @test **/ + #[Test] public function a_multilingual_route_can_be_signed_with_temporary_signature(): void { Route::multilingual('test'); From d100bdf8347184577350a36d2331ac33442a7471 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Mar 2026 20:52:54 +0000 Subject: [PATCH 3/4] Bump minimum PHP to 8.3 for Laravel 13 compatibility Co-authored-by: chinleung <19669331+chinleung@users.noreply.github.com> --- .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 06cd129..5b0cbeb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: true matrix: - php: ['8.2', '8.3', '8.4'] + php: ['8.3', '8.4'] stability: [prefer-lowest, prefer-stable] steps: diff --git a/composer.json b/composer.json index 6ed7535..3f9ed55 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": "^8.2", + "php": "^8.3", "chinleung/laravel-locales": "^2.0", "illuminate/support": "^12.0|^13.0" }, From 6964bfc9ef283eb9dd190794bf8c39fbca9952df Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Mar 2026 21:17:43 +0000 Subject: [PATCH 4/4] Drop Laravel v12 support, keep only Laravel v13 Co-authored-by: chinleung <19669331+chinleung@users.noreply.github.com> --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 3f9ed55..c757899 100644 --- a/composer.json +++ b/composer.json @@ -21,11 +21,11 @@ "require": { "php": "^8.3", "chinleung/laravel-locales": "^2.0", - "illuminate/support": "^12.0|^13.0" + "illuminate/support": "^13.0" }, "require-dev": { - "orchestra/testbench": "^8.0|^9.0|^10.0|^11.0", - "phpunit/phpunit": "^9.5.10|^10.5|^11.5.3|^12.5.12" + "orchestra/testbench": "^11.0", + "phpunit/phpunit": "^12.5.12" }, "autoload": { "psr-4": {