Skip to content

Commit 0454e21

Browse files
Add support for Laravel 11 (#602)
* Add support for Laravel 11 * Fix styling * Update all dependencies * Update github tests * Update github tests * Fix styling * Remove unused file --------- Co-authored-by: arthurkirkosa <[email protected]>
1 parent 2ca67dd commit 0454e21

File tree

10 files changed

+41
-42
lines changed

10 files changed

+41
-42
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ubuntu-latest, windows-latest]
12-
php: [8.1, 8.2]
13-
laravel: [10.*]
12+
php: [8.2]
13+
laravel: [11.*]
1414
stability: [prefer-lowest, prefer-stable]
1515
include:
16-
- laravel: 10.*
17-
testbench: 8.*
16+
- laravel: 11.*
17+
testbench: 9.*
1818

1919
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2020

composer.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^8.1",
22-
"illuminate/contracts": "^10.0",
21+
"php": "^8.2",
22+
"illuminate/contracts": "^11.0",
2323
"laravel/pint": "^1.0",
24-
"spatie/laravel-data": "dev-main",
24+
"spatie/laravel-data": "^4.4",
2525
"spatie/laravel-package-tools": "^1.12",
2626
"spatie/once": "^3.0"
2727
},
2828
"require-dev": {
2929
"brianium/paratest": "^7.0.6",
30-
"doctrine/dbal": "^3.0",
31-
"nunomaduro/collision": "^7.0",
32-
"openai-php/laravel": "^0.3.1",
33-
"orchestra/testbench": "^8.0",
30+
"doctrine/dbal": "^3.0|^4.0",
31+
"nunomaduro/collision": "^8.1",
32+
"openai-php/laravel": "^0.8.1",
33+
"orchestra/testbench": "^9.0",
3434
"phpstan/extension-installer": "^1.1",
3535
"phpstan/phpstan-deprecation-rules": "^1.0",
3636
"phpstan/phpstan-phpunit": "^1.0",
37-
"phpunit/phpunit": "^10.0",
37+
"phpunit/phpunit": "^10.0|^11.0",
3838
"spatie/laravel-ray": "^1.9",
39-
"vimeo/psalm": "^5.6"
39+
"vimeo/psalm": "^6.0@dev"
4040
},
4141
"autoload": {
4242
"files": [
@@ -75,5 +75,6 @@
7575
}
7676
}
7777
},
78-
"minimum-stability": "dev"
78+
"minimum-stability": "dev",
79+
"prefer-stable": true
7980
}

src/Fields/Field.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Field extends OrganicField implements JsonSerializable
2222
/**
2323
* The resource associated with the field.
2424
*
25-
* @var Repository
25+
* @var Repository
2626
*/
2727
public $repository;
2828

src/Repositories/Repository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ public function __call($method, $parameters)
327327
* However all options could be customized by passing an $options argument
328328
*
329329
* @param bool $wrap Choose the routes defined in the @routes method, should be wrapped in a group with attributes by default.
330-
* If true then all routes will be grouped in a configuration attributes passed by restify, otherwise
331-
* you should take care of that, by adding $router->group($attributes) in the @routes method
330+
* If true then all routes will be grouped in a configuration attributes passed by restify, otherwise
331+
* you should take care of that, by adding $router->group($attributes) in the @routes method
332332
*/
333333
public static function routes(Router $router, array $attributes, $wrap = true)
334334
{

tests/Actions/FieldActionTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
use Binaryk\LaravelRestify\Tests\Fixtures\Post\PostRepository;
1010
use Binaryk\LaravelRestify\Tests\IntegrationTestCase;
1111
use Illuminate\Testing\Fluent\AssertableJson;
12+
use PHPUnit\Framework\Attributes\Test;
1213

1314
class FieldActionTest extends IntegrationTestCase
1415
{
15-
/** * @test */
16+
#[Test]
1617
public function can_use_actionable_field(): void
1718
{
1819
$action = new class() extends Action
@@ -52,7 +53,7 @@ public function handle(RestifyRequest $request, Post $post)
5253

5354
}
5455

55-
/** @test */
56+
#[Test]
5657
public function can_use_actionable_field_on_bulk_store(): void
5758
{
5859
$action = new class() extends Action
@@ -97,7 +98,7 @@ public function handle(RestifyRequest $request, Post $post, int $row)
9798
);
9899
}
99100

100-
/** @test */
101+
#[Test]
101102
public function can_use_actionable_field_on_bulk_update(): void
102103
{
103104
$action = new class() extends Action

tests/Controllers/Index/IndexRelatedFeatureTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Illuminate\Foundation\Testing\RefreshDatabase;
2525
use Illuminate\Http\Request;
2626
use Illuminate\Testing\Fluent\AssertableJson;
27+
use PHPUnit\Framework\Attributes\Test;
2728

2829
class IndexRelatedFeatureTest extends IntegrationTestCase
2930
{
@@ -197,7 +198,7 @@ public function test_repository_can_resolve_related_using_callables(): void
197198
);
198199
}
199200

200-
/** * @test */
201+
#[Test]
201202
public function it_can_paginate_keeping_relationships(): void
202203
{
203204
PostRepository::$related = [
@@ -228,7 +229,7 @@ public function it_can_paginate_keeping_relationships(): void
228229
);
229230
}
230231

231-
/** * @test */
232+
#[Test]
232233
public function it_will_call_fields_method_for_related(): void
233234
{
234235
UserRepository::partialMock()

tests/Controllers/Index/NestedRepositoryControllerTest.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
use Binaryk\LaravelRestify\Tests\IntegrationTestCase;
1313
use Illuminate\Support\Facades\Gate;
1414
use Illuminate\Testing\Fluent\AssertableJson;
15+
use PHPUnit\Framework\Attributes\Test;
1516

1617
class NestedRepositoryControllerTest extends IntegrationTestCase
1718
{
18-
/** * @test */
19+
#[Test]
1920
public function it_can_list_nested(): void
2021
{
2122
UserRepository::$related = [
@@ -33,7 +34,7 @@ public function it_can_list_nested(): void
3334
$this->getJson(UserRepository::route('1/posts'))->assertForbidden();
3435
}
3536

36-
/** * @test */
37+
#[Test]
3738
public function it_can_show_nested_using_identifier(): void
3839
{
3940
$post = PostFactory::one([
@@ -56,7 +57,7 @@ public function it_can_show_nested_using_identifier(): void
5657
$this->getJson(UserRepository::route("$post->user_id/posts/$post->id"))->assertForbidden();
5758
}
5859

59-
/** * @test */
60+
#[Test]
6061
public function it_can_store_nested_related(): void
6162
{
6263
UserRepository::$related = [
@@ -83,9 +84,7 @@ public function it_can_store_nested_related(): void
8384
])->assertForbidden();
8485
}
8586

86-
/**
87-
* @test
88-
*/
87+
#[Test]
8988
public function it_can_update_nested_related(): void
9089
{
9190
UserRepository::$related = [
@@ -117,9 +116,7 @@ public function it_can_update_nested_related(): void
117116
])->assertForbidden();
118117
}
119118

120-
/**
121-
* @test
122-
*/
119+
#[Test]
123120
public function it_can_delete_nested_related(): void
124121
{
125122
UserRepository::$related = [
@@ -139,9 +136,7 @@ public function it_can_delete_nested_related(): void
139136
$this->deleteJson(UserRepository::route("$post->user_id/posts/$post->id"))->assertForbidden();
140137
}
141138

142-
/**
143-
* @test
144-
*/
139+
#[Test]
145140
public function it_will_apply_policies_when_nested_requested(): void
146141
{
147142
$_SERVER['restify.post.delete'] = false;

tests/Controllers/Index/RepositoryIndexControllerTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
use Binaryk\LaravelRestify\Tests\IntegrationTestCase;
1212
use Illuminate\Foundation\Testing\RefreshDatabase;
1313
use Illuminate\Testing\Fluent\AssertableJson;
14+
use PHPUnit\Framework\Attributes\Test;
1415

1516
class RepositoryIndexControllerTest extends IntegrationTestCase
1617
{
1718
use RefreshDatabase;
1819

19-
/** * @test */
20+
#[Test]
2021
public function it_can_paginate(): void
2122
{
2223
PostFactory::many(15);
@@ -65,7 +66,7 @@ public function it_can_paginate(): void
6566
);
6667
}
6768

68-
/** * @test */
69+
#[Test]
6970
public function it_can_search_using_query(): void
7071
{
7172
PostFactory::one([
@@ -91,7 +92,7 @@ public function it_can_search_using_query(): void
9192
]))->assertJson(fn (AssertableJson $json) => $json->count('data', 2)->etc());
9293
}
9394

94-
/** * @test */
95+
#[Test]
9596
public function it_can_sort_using_query(): void
9697
{
9798
PostFactory::one([
@@ -125,7 +126,7 @@ public function it_can_sort_using_query(): void
125126
);
126127
}
127128

128-
/** * @test */
129+
#[Test]
129130
public function it_can_return_related_entity(): void
130131
{
131132
PostRepository::$related = [

tests/Controllers/RepositoryLoadedFromServiceProviderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Binaryk\LaravelRestify\Restify;
66
use Binaryk\LaravelRestify\Tests\Concerns\WithRepositoriesDataProvider;
77
use Binaryk\LaravelRestify\Tests\IntegrationTestCase;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89

910
class RepositoryLoadedFromServiceProviderTest extends IntegrationTestCase
1011
{
@@ -22,7 +23,7 @@ protected function tearDown(): void
2223
parent::tearDown();
2324
}
2425

25-
/** @dataProvider repositoryPathsFromFixtures */
26+
#[DataProvider('repositoryPathsFromFixtures')]
2627
public function test_repositories_can_be_loaded_with_service_provider_register_method(
2728
string $directory,
2829
string $namespace,

tests/Unit/RepositoriesResolvedFromNamespaceTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Binaryk\LaravelRestify\Tests\Concerns\WithRepositoriesDataProvider;
77
use Binaryk\LaravelRestify\Tests\IntegrationTestCase;
88
use Orchestra\Testbench\TestCase;
9+
use PHPUnit\Framework\Attributes\DataProvider;
910

1011
class RepositoriesResolvedFromNamespaceTest extends IntegrationTestCase
1112
{
@@ -46,9 +47,7 @@ public function test_repository_can_be_resolved_from_app_namespace(): void
4647
);
4748
}
4849

49-
/**
50-
* @dataProvider repositoryPathsFromFixtures
51-
*/
50+
#[DataProvider('repositoryPathsFromFixtures')]
5251
public function test_repository_can_be_resolved_from_any_namespace(string $directory, string $namespace): void
5352
{
5453
Restify::repositoriesFrom(

0 commit comments

Comments
 (0)