From 40663b630a32f4c11c874af93ddbacfd1a38819c Mon Sep 17 00:00:00 2001 From: Shift Date: Sun, 10 Mar 2024 10:06:48 +0000 Subject: [PATCH 1/6] Bump PHPUnit dependencies --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b324806..9f962d7 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ }, "require-dev": { "orchestra/testbench": "^5.0|^6.0|^7.0|^8.0", - "phpunit/phpunit": "^8.0|^9.0" + "phpunit/phpunit": "^10.0" }, "scripts": { "test": "phpunit" From 147e104a9d8d08a24099af1cd565bdb36ac57e22 Mon Sep 17 00:00:00 2001 From: Shift Date: Sun, 10 Mar 2024 10:06:48 +0000 Subject: [PATCH 2/6] Ignore PHPUnit cache folder --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fe1052a..80742d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /vendor /phpunit.xml composer.lock -/.phpunit.result.cache +/.phpunit.cache From db37bcdd55ba200276201f4f9102b3ebff70eb41 Mon Sep 17 00:00:00 2001 From: Shift Date: Sun, 10 Mar 2024 10:06:48 +0000 Subject: [PATCH 3/6] Adopt PHP attributes in test classes --- tests/Feature/UriTranslatorTest.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/Feature/UriTranslatorTest.php b/tests/Feature/UriTranslatorTest.php index 41267b6..62d379c 100644 --- a/tests/Feature/UriTranslatorTest.php +++ b/tests/Feature/UriTranslatorTest.php @@ -2,12 +2,13 @@ namespace CodeZero\UriTranslator\Tests\Feature; +use PHPUnit\Framework\Attributes\Test; use CodeZero\UriTranslator\Tests\TestCase; use Illuminate\Support\Facades\Lang; class UriTranslatorTest extends TestCase { - /** @test */ + #[Test] public function it_translates_every_segment_in_a_uri_to_the_current_locale() { $this->setTranslations([ @@ -26,7 +27,7 @@ public function it_translates_every_segment_in_a_uri_to_the_current_locale() $this->assertEquals('mijn/nieuwe/pagina', trans()->uri('my/new/page')); } - /** @test */ + #[Test] public function it_translates_every_segment_in_a_uri_to_the_given_locale() { $this->setTranslations([ @@ -40,7 +41,7 @@ public function it_translates_every_segment_in_a_uri_to_the_given_locale() $this->assertEquals('mijn/nieuwe/pagina', Lang::uri('my/new/page', 'nl')); } - /** @test */ + #[Test] public function it_uses_the_original_values_if_a_translation_does_not_exist() { $this->setTranslations([ @@ -54,7 +55,7 @@ public function it_uses_the_original_values_if_a_translation_does_not_exist() $this->assertEquals('my/new/page', Lang::uri('my/new/page', 'fr')); } - /** @test */ + #[Test] public function it_ignores_trailing_slashes() { $this->setTranslations([ @@ -68,7 +69,7 @@ public function it_ignores_trailing_slashes() $this->assertEquals('mijn/nieuwe/pagina', Lang::uri('/my/new/page/', 'nl')); } - /** @test */ + #[Test] public function it_skips_placeholders_in_a_uri() { $this->setTranslations([ @@ -80,7 +81,7 @@ public function it_skips_placeholders_in_a_uri() $this->assertEquals('artikels/{articles}', Lang::uri('articles/{articles}', 'nl')); } - /** @test */ + #[Test] public function you_can_translate_a_full_uri() { $this->setTranslations([ @@ -94,7 +95,7 @@ public function you_can_translate_a_full_uri() $this->assertEquals('producten/glazen', Lang::uri('products/glass', 'nl')); } - /** @test */ + #[Test] public function you_can_translate_a_full_uri_with_placeholder() { $this->setTranslations([ @@ -108,7 +109,7 @@ public function you_can_translate_a_full_uri_with_placeholder() $this->assertEquals('producten/glazen/{type}', Lang::uri('products/glass/{type}', 'nl')); } - /** @test */ + #[Test] public function you_can_specify_a_namespace() { $this->setTranslations([ @@ -120,7 +121,7 @@ public function you_can_specify_a_namespace() $this->assertEquals('artikels/{article}', Lang::uri('articles/{article}', 'nl', 'blog')); } - /** @test */ + #[Test] public function the_uri_macro_is_available_via_the_trans_helper() { $this->setTranslations([ From 46a07a72725f40effd0ac9b5c43279b1723d49bd Mon Sep 17 00:00:00 2001 From: Shift Date: Sun, 10 Mar 2024 10:06:48 +0000 Subject: [PATCH 4/6] Add return types to test methods --- tests/Feature/UriTranslatorTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Feature/UriTranslatorTest.php b/tests/Feature/UriTranslatorTest.php index 62d379c..50dc6c8 100644 --- a/tests/Feature/UriTranslatorTest.php +++ b/tests/Feature/UriTranslatorTest.php @@ -9,7 +9,7 @@ class UriTranslatorTest extends TestCase { #[Test] - public function it_translates_every_segment_in_a_uri_to_the_current_locale() + public function it_translates_every_segment_in_a_uri_to_the_current_locale(): void { $this->setTranslations([ 'nl' => [ @@ -28,7 +28,7 @@ public function it_translates_every_segment_in_a_uri_to_the_current_locale() } #[Test] - public function it_translates_every_segment_in_a_uri_to_the_given_locale() + public function it_translates_every_segment_in_a_uri_to_the_given_locale(): void { $this->setTranslations([ 'nl' => [ @@ -42,7 +42,7 @@ public function it_translates_every_segment_in_a_uri_to_the_given_locale() } #[Test] - public function it_uses_the_original_values_if_a_translation_does_not_exist() + public function it_uses_the_original_values_if_a_translation_does_not_exist(): void { $this->setTranslations([ 'nl' => [ @@ -56,7 +56,7 @@ public function it_uses_the_original_values_if_a_translation_does_not_exist() } #[Test] - public function it_ignores_trailing_slashes() + public function it_ignores_trailing_slashes(): void { $this->setTranslations([ 'nl' => [ @@ -70,7 +70,7 @@ public function it_ignores_trailing_slashes() } #[Test] - public function it_skips_placeholders_in_a_uri() + public function it_skips_placeholders_in_a_uri(): void { $this->setTranslations([ 'nl' => [ @@ -82,7 +82,7 @@ public function it_skips_placeholders_in_a_uri() } #[Test] - public function you_can_translate_a_full_uri() + public function you_can_translate_a_full_uri(): void { $this->setTranslations([ 'nl' => [ @@ -96,7 +96,7 @@ public function you_can_translate_a_full_uri() } #[Test] - public function you_can_translate_a_full_uri_with_placeholder() + public function you_can_translate_a_full_uri_with_placeholder(): void { $this->setTranslations([ 'nl' => [ @@ -110,7 +110,7 @@ public function you_can_translate_a_full_uri_with_placeholder() } #[Test] - public function you_can_specify_a_namespace() + public function you_can_specify_a_namespace(): void { $this->setTranslations([ 'nl' => [ @@ -122,7 +122,7 @@ public function you_can_specify_a_namespace() } #[Test] - public function the_uri_macro_is_available_via_the_trans_helper() + public function the_uri_macro_is_available_via_the_trans_helper(): void { $this->setTranslations([ 'nl' => [ From 1b131ae99be05fcff547647ae065fd9a2faf573c Mon Sep 17 00:00:00 2001 From: Shift Date: Sun, 10 Mar 2024 10:06:48 +0000 Subject: [PATCH 5/6] Define test classes as `final` --- tests/Feature/UriTranslatorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/UriTranslatorTest.php b/tests/Feature/UriTranslatorTest.php index 50dc6c8..15dec40 100644 --- a/tests/Feature/UriTranslatorTest.php +++ b/tests/Feature/UriTranslatorTest.php @@ -6,7 +6,7 @@ use CodeZero\UriTranslator\Tests\TestCase; use Illuminate\Support\Facades\Lang; -class UriTranslatorTest extends TestCase +final class UriTranslatorTest extends TestCase { #[Test] public function it_translates_every_segment_in_a_uri_to_the_current_locale(): void From 10ee81283359c9292d218b57e35e24886a2a25b3 Mon Sep 17 00:00:00 2001 From: Ivan Vermeyen Date: Sun, 10 Mar 2024 13:26:02 +0100 Subject: [PATCH 6/6] Support only Laravel 10 and newer --- .github/workflows/run-tests.yml | 23 ++++++----------------- .gitignore | 1 + README.md | 6 +++--- composer.json | 13 +++++-------- phpunit.xml.dist | 22 +++++++++++----------- 5 files changed, 26 insertions(+), 39 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 9e9fd1f..4554c07 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -8,28 +8,17 @@ jobs: strategy: fail-fast: true matrix: - php: [ 8.0, 8.1 ] - laravel: [ 8.*, 9.*, 10.* ] + php: [ 8.1, 8.2, 8.3 ] + laravel: [ 10.*, 11.* ] dependency-version: [ prefer-stable ] exclude: - - laravel: 10.* - php: 8.0 + - laravel: 11.* + php: 8.1 include: - - laravel: 7.* - php: 7.2 - testbench: 5.* - - laravel: 7.* - php: 8.0 - testbench: 5.* - - laravel: 8.* - php: 7.3 - testbench: 6.* - - laravel: 8.* - testbench: 6.* - - laravel: 9.* - testbench: 7.* - laravel: 10.* testbench: 8.* + - laravel: 11.* + testbench: 9.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} diff --git a/.gitignore b/.gitignore index 80742d3..667fe37 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /phpunit.xml composer.lock /.phpunit.cache +/.phpunit.result.cache diff --git a/README.md b/README.md index a19a109..8323ead 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Laravel URI Translator [![GitHub release](https://img.shields.io/github/release/codezero-be/laravel-uri-translator.svg?style=flat-square)](https://github.com/codezero-be/laravel-uri-translator/releases) -[![Laravel](https://img.shields.io/badge/laravel-10-red?style=flat-square&logo=laravel&logoColor=white)](https://laravel.com) +[![Laravel](https://img.shields.io/badge/laravel-11-red?style=flat-square&logo=laravel&logoColor=white)](https://laravel.com) [![License](https://img.shields.io/packagist/l/codezero/laravel-uri-translator.svg?style=flat-square)](LICENSE.md) [![Build Status](https://img.shields.io/github/actions/workflow/status/codezero-be/laravel-uri-translator/run-tests.yml?style=flat-square&logo=github&logoColor=white&label=tests)](https://github.com/codezero-be/laravel-uri-translator/actions) [![Code Coverage](https://img.shields.io/codacy/coverage/ad6fcea152b449d380a187a375d0f7d7/master?style=flat-square)](https://app.codacy.com/gh/codezero-be/laravel-uri-translator) @@ -17,8 +17,8 @@ Parameters will not be translated by this macro. That remains the responsibility ## ✅ Requirements -- PHP >= 7.2.5 -- Laravel >= 7.0 +- PHP >= 8.1 +- Laravel >= 10.0 ## 📦 Install diff --git a/composer.json b/composer.json index 9f962d7..eb541e2 100644 --- a/composer.json +++ b/composer.json @@ -20,12 +20,12 @@ } ], "require": { - "php": "^7.2.5|^8.0", - "illuminate/support": "^7.0|^8.0|^9.0|^10.0" + "php": "^8.1", + "illuminate/support": "^10.0|^11.0" }, "require-dev": { - "orchestra/testbench": "^5.0|^6.0|^7.0|^8.0", - "phpunit/phpunit": "^10.0" + "orchestra/testbench": "^8.0|^9.0", + "phpunit/phpunit": "^10.5" }, "scripts": { "test": "phpunit" @@ -50,10 +50,7 @@ "config": { "preferred-install": "dist", "sort-packages": true, - "optimize-autoloader": true, - "allow-plugins": { - "kylekatarnls/update-helper": true - } + "optimize-autoloader": true }, "minimum-stability": "dev", "prefer-stable": true diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 461f1f9..3029c21 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,27 @@ - + stopOnFailure="false" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" + cacheDirectory=".phpunit.cache" + backupStaticProperties="false"> ./tests/Feature - - - ./src - - + + + ./src + +