Skip to content

Commit 9d94312

Browse files
Add support for Laravel 11 and PHPUnit 10 (#1)
* Bump PHPUnit dependencies * Ignore PHPUnit cache folder * Adopt PHP attributes in test classes * Add return types to test methods * Define test classes as `final` * Support only Laravel 10 and newer --------- Co-authored-by: Shift <[email protected]>
1 parent 30e630d commit 9d94312

File tree

6 files changed

+46
-58
lines changed

6 files changed

+46
-58
lines changed

.github/workflows/run-tests.yml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,17 @@ jobs:
88
strategy:
99
fail-fast: true
1010
matrix:
11-
php: [ 8.0, 8.1 ]
12-
laravel: [ 8.*, 9.*, 10.* ]
11+
php: [ 8.1, 8.2, 8.3 ]
12+
laravel: [ 10.*, 11.* ]
1313
dependency-version: [ prefer-stable ]
1414
exclude:
15-
- laravel: 10.*
16-
php: 8.0
15+
- laravel: 11.*
16+
php: 8.1
1717
include:
18-
- laravel: 7.*
19-
php: 7.2
20-
testbench: 5.*
21-
- laravel: 7.*
22-
php: 8.0
23-
testbench: 5.*
24-
- laravel: 8.*
25-
php: 7.3
26-
testbench: 6.*
27-
- laravel: 8.*
28-
testbench: 6.*
29-
- laravel: 9.*
30-
testbench: 7.*
3118
- laravel: 10.*
3219
testbench: 8.*
20+
- laravel: 11.*
21+
testbench: 9.*
3322

3423
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
3524

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/vendor
22
/phpunit.xml
33
composer.lock
4+
/.phpunit.cache
45
/.phpunit.result.cache

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Laravel URI Translator
22

33
[![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)
4-
[![Laravel](https://img.shields.io/badge/laravel-10-red?style=flat-square&logo=laravel&logoColor=white)](https://laravel.com)
4+
[![Laravel](https://img.shields.io/badge/laravel-11-red?style=flat-square&logo=laravel&logoColor=white)](https://laravel.com)
55
[![License](https://img.shields.io/packagist/l/codezero/laravel-uri-translator.svg?style=flat-square)](LICENSE.md)
66
[![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)
77
[![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
1717

1818
## ✅ Requirements
1919

20-
- PHP >= 7.2.5
21-
- Laravel >= 7.0
20+
- PHP >= 8.1
21+
- Laravel >= 10.0
2222

2323
## 📦 Install
2424

composer.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^7.2.5|^8.0",
24-
"illuminate/support": "^7.0|^8.0|^9.0|^10.0"
23+
"php": "^8.1",
24+
"illuminate/support": "^10.0|^11.0"
2525
},
2626
"require-dev": {
27-
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0",
28-
"phpunit/phpunit": "^8.0|^9.0"
27+
"orchestra/testbench": "^8.0|^9.0",
28+
"phpunit/phpunit": "^10.5"
2929
},
3030
"scripts": {
3131
"test": "phpunit"
@@ -50,10 +50,7 @@
5050
"config": {
5151
"preferred-install": "dist",
5252
"sort-packages": true,
53-
"optimize-autoloader": true,
54-
"allow-plugins": {
55-
"kylekatarnls/update-helper": true
56-
}
53+
"optimize-autoloader": true
5754
},
5855
"minimum-stability": "dev",
5956
"prefer-stable": true

phpunit.xml.dist

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
backupGlobals="false"
44
bootstrap="vendor/autoload.php"
55
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
96
processIsolation="false"
10-
stopOnFailure="false">
7+
stopOnFailure="false"
8+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
9+
cacheDirectory=".phpunit.cache"
10+
backupStaticProperties="false">
1111
<testsuites>
1212
<testsuite name="Feature">
1313
<directory suffix="Test.php">./tests/Feature</directory>
1414
</testsuite>
1515
</testsuites>
16-
<filter>
17-
<whitelist processUncoveredFilesFromWhitelist="true">
18-
<directory suffix=".php">./src</directory>
19-
</whitelist>
20-
</filter>
2116
<php>
2217
<env name="APP_ENV" value="testing"/>
2318
<env name="CACHE_DRIVER" value="array"/>
2419
<env name="SESSION_DRIVER" value="array"/>
2520
<env name="QUEUE_DRIVER" value="sync"/>
2621
</php>
22+
<source>
23+
<include>
24+
<directory suffix=".php">./src</directory>
25+
</include>
26+
</source>
2727
</phpunit>

tests/Feature/UriTranslatorTest.php

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace CodeZero\UriTranslator\Tests\Feature;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use CodeZero\UriTranslator\Tests\TestCase;
67
use Illuminate\Support\Facades\Lang;
78

8-
class UriTranslatorTest extends TestCase
9+
final class UriTranslatorTest extends TestCase
910
{
10-
/** @test */
11-
public function it_translates_every_segment_in_a_uri_to_the_current_locale()
11+
#[Test]
12+
public function it_translates_every_segment_in_a_uri_to_the_current_locale(): void
1213
{
1314
$this->setTranslations([
1415
'nl' => [
@@ -26,8 +27,8 @@ public function it_translates_every_segment_in_a_uri_to_the_current_locale()
2627
$this->assertEquals('mijn/nieuwe/pagina', trans()->uri('my/new/page'));
2728
}
2829

29-
/** @test */
30-
public function it_translates_every_segment_in_a_uri_to_the_given_locale()
30+
#[Test]
31+
public function it_translates_every_segment_in_a_uri_to_the_given_locale(): void
3132
{
3233
$this->setTranslations([
3334
'nl' => [
@@ -40,8 +41,8 @@ public function it_translates_every_segment_in_a_uri_to_the_given_locale()
4041
$this->assertEquals('mijn/nieuwe/pagina', Lang::uri('my/new/page', 'nl'));
4142
}
4243

43-
/** @test */
44-
public function it_uses_the_original_values_if_a_translation_does_not_exist()
44+
#[Test]
45+
public function it_uses_the_original_values_if_a_translation_does_not_exist(): void
4546
{
4647
$this->setTranslations([
4748
'nl' => [
@@ -54,8 +55,8 @@ public function it_uses_the_original_values_if_a_translation_does_not_exist()
5455
$this->assertEquals('my/new/page', Lang::uri('my/new/page', 'fr'));
5556
}
5657

57-
/** @test */
58-
public function it_ignores_trailing_slashes()
58+
#[Test]
59+
public function it_ignores_trailing_slashes(): void
5960
{
6061
$this->setTranslations([
6162
'nl' => [
@@ -68,8 +69,8 @@ public function it_ignores_trailing_slashes()
6869
$this->assertEquals('mijn/nieuwe/pagina', Lang::uri('/my/new/page/', 'nl'));
6970
}
7071

71-
/** @test */
72-
public function it_skips_placeholders_in_a_uri()
72+
#[Test]
73+
public function it_skips_placeholders_in_a_uri(): void
7374
{
7475
$this->setTranslations([
7576
'nl' => [
@@ -80,8 +81,8 @@ public function it_skips_placeholders_in_a_uri()
8081
$this->assertEquals('artikels/{articles}', Lang::uri('articles/{articles}', 'nl'));
8182
}
8283

83-
/** @test */
84-
public function you_can_translate_a_full_uri()
84+
#[Test]
85+
public function you_can_translate_a_full_uri(): void
8586
{
8687
$this->setTranslations([
8788
'nl' => [
@@ -94,8 +95,8 @@ public function you_can_translate_a_full_uri()
9495
$this->assertEquals('producten/glazen', Lang::uri('products/glass', 'nl'));
9596
}
9697

97-
/** @test */
98-
public function you_can_translate_a_full_uri_with_placeholder()
98+
#[Test]
99+
public function you_can_translate_a_full_uri_with_placeholder(): void
99100
{
100101
$this->setTranslations([
101102
'nl' => [
@@ -108,8 +109,8 @@ public function you_can_translate_a_full_uri_with_placeholder()
108109
$this->assertEquals('producten/glazen/{type}', Lang::uri('products/glass/{type}', 'nl'));
109110
}
110111

111-
/** @test */
112-
public function you_can_specify_a_namespace()
112+
#[Test]
113+
public function you_can_specify_a_namespace(): void
113114
{
114115
$this->setTranslations([
115116
'nl' => [
@@ -120,8 +121,8 @@ public function you_can_specify_a_namespace()
120121
$this->assertEquals('artikels/{article}', Lang::uri('articles/{article}', 'nl', 'blog'));
121122
}
122123

123-
/** @test */
124-
public function the_uri_macro_is_available_via_the_trans_helper()
124+
#[Test]
125+
public function the_uri_macro_is_available_via_the_trans_helper(): void
125126
{
126127
$this->setTranslations([
127128
'nl' => [

0 commit comments

Comments
 (0)