Skip to content

Commit eb3dd43

Browse files
Feature/laravel 13 (#84)
* Laravel 13 - Update dependencies, ci, and switch to uuidv7 * Update for one deprecation and remove package not supported in laravel 13 * Update to phpunit 12
1 parent 42a5f9e commit eb3dd43

14 files changed

Lines changed: 34 additions & 29 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ on:
99

1010
jobs:
1111
tests:
12-
runs-on: ubuntu-24.04
12+
runs-on: ubuntu-latest
1313

1414
strategy:
1515
fail-fast: false
1616
matrix:
1717
stability: [prefer-stable]
18-
php: [8.2, 8.3, 8.4]
19-
laravel: [12]
18+
php: [8.3, 8.4, 8.5]
19+
laravel: [13]
2020

2121
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
2222

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,20 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^8.2",
14-
"api-ecosystem-for-laravel/dingo-api": "^4.6",
15-
"php-open-source-saver/jwt-auth": "^2.8",
16-
"illuminate/support": "^12.0",
13+
"php": "^8.3",
14+
"api-ecosystem-for-laravel/dingo-api": "^4.8",
15+
"php-open-source-saver/jwt-auth": "^2.9",
16+
"illuminate/support": "^13.0",
1717
"ramsey/uuid": "^4.7",
1818
"nesbot/carbon": "^3.0"
1919
},
2020
"require-dev": {
2121
"ext-json": "*",
22-
"beyondcode/laravel-dump-server": "^2.1",
2322
"fakerphp/faker": "^1.24",
2423
"mockery/mockery": "^1.6",
2524
"nunomaduro/collision": "^8.6",
26-
"phpunit/phpunit": "^11.5",
27-
"orchestra/testbench": "^10.3"
25+
"phpunit/phpunit": "^12.0",
26+
"orchestra/testbench": "^11.3"
2827
},
2928
"autoload": {
3029
"psr-4": {

src/Models/RestfulModel.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,15 @@ public function getValidationMessages(): array
9494
*
9595
* Add various functionality in the model lifecycle hooks
9696
*/
97-
public static function boot(): void
97+
public static function booted(): void
9898
{
99-
parent::boot();
100-
10199
// Add functionality for creating a model
102100
static::creating(function (self $model) {
103101
// If the PK(s) are missing, generate them
104102
$uuidKeyName = $model->getKeyName();
105103

106104
if ($uuidKeyName && ! $model->incrementing && ! is_array($uuidKeyName) && ! array_key_exists($uuidKeyName, $model->getAttributes())) {
107-
$model->$uuidKeyName = Uuid::uuid4()->toString();
105+
$model->$uuidKeyName = Uuid::uuid7()->toString();
108106
}
109107
});
110108

src/Services/RestfulService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function persistResource(RestfulModel $resource)
155155
*
156156
* @throws StoreResourceFailedException
157157
*/
158-
public function validateResource($resource, array $data = null)
158+
public function validateResource($resource, ?array $data = null)
159159
{
160160
// If no data is provided, validate the resource against it's present attributes
161161
if (is_null($data)) {

test/app/Http/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Kernel extends HttpKernel
3333
\Illuminate\Session\Middleware\StartSession::class,
3434
// \Illuminate\Session\Middleware\AuthenticateSession::class,
3535
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
36-
\App\Http\Middleware\VerifyCsrfToken::class,
36+
\App\Http\Middleware\PreventRequestForgery::class,
3737
\Illuminate\Routing\Middleware\SubstituteBindings::class,
3838
],
3939

test/app/Http/Middleware/VerifyCsrfToken.php renamed to test/app/Http/Middleware/PreventRequestForgery.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace App\Http\Middleware;
44

5-
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
5+
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery as Middleware;
66

7-
class VerifyCsrfToken extends Middleware
7+
class PreventRequestForgery extends Middleware
88
{
99
/**
1010
* Indicates whether the XSRF-TOKEN cookie should be set on the response.

test/tests/A/FirstTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
namespace Specialtactics\L5Api\Tests\A;
44

55
use Specialtactics\L5Api\Tests\BaseTestCase;
6+
use PHPUnit\Framework\Attributes\Test;
67

78
class FirstTest extends BaseTestCase
89
{
910
/**
1011
* @testdox Consumes testing bootstrap time
11-
* @test
1212
*/
13+
#[Test]
1314
public function testBootstrapTime()
1415
{
1516
$this->assertTrue(true);

test/tests/Api/Patch/PatchTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
namespace Specialtactics\L5Api\Tests\Api\Patch;
44

55
use Specialtactics\L5Api\Tests\AppTestCase;
6+
use PHPUnit\Framework\Attributes\Test;
67

78
class PatchTest extends AppTestCase
89
{
910
/**
1011
* @testdox Updating a forum description
11-
* @test
1212
*/
13+
#[Test]
1314
public function patchForumDescription()
1415
{
1516
$description = 'Lorum Ipsum new discussions';

test/tests/Unit/BaseTransformerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Ramsey\Uuid\Uuid;
66
use Specialtactics\L5Api\Tests\AppTestCase;
7+
use PHPUnit\Framework\Attributes\Test;
78
use Specialtactics\L5Api\Tests\Fixtures\Models\ModelWithCasts;
89
use Specialtactics\L5Api\Tests\Fixtures\Models\ModelWithIdPK;
910
use Specialtactics\L5Api\Transformers\RestfulTransformer;
@@ -14,8 +15,8 @@ class BaseTransformerTest extends AppTestCase
1415
* Check that if a model has a primary key called "id", that it will be transformed correctly,
1516
* rather than being unset
1617
*
17-
* @test
1818
*/
19+
#[Test]
1920
public function canTransformModelWithPKOfId()
2021
{
2122
$model = new ModelWithIdPK(['example_attribute' => 'abc123']);
@@ -30,8 +31,8 @@ public function canTransformModelWithPKOfId()
3031
/**
3132
* Make sure that an array cast attribute is transformed correctly, in situations when it's blank
3233
*
33-
* @test
3434
*/
35+
#[Test]
3536
public function nullArrayCastWillBeEmptyArray()
3637
{
3738
//

test/tests/Unit/Helpers/KeyCaseTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Specialtactics\L5Api\Tests\Unit\Helpers;
44

55
use Specialtactics\L5Api\Tests\AppTestCase;
6+
use PHPUnit\Framework\Attributes\Test;
67
use Specialtactics\L5Api\Helpers;
78

89
class KeyCaseTest extends AppTestCase
@@ -114,26 +115,26 @@ class KeyCaseTest extends AppTestCase
114115
];
115116

116117
/**
117-
* @test
118118
*/
119+
#[Test]
119120
public function camelCaseArrayKeys()
120121
{
121122
$result = Helpers::camelCaseArrayKeys(self::MIXED_CASES);
122123
$this->assertEqualsWithDelta($result, self::AFTER_CAMEL, self::MAX_DEPTH);
123124
}
124125

125126
/**
126-
* @test
127127
*/
128+
#[Test]
128129
public function snakeCaseArrayKeys()
129130
{
130131
$result = Helpers::snakeCaseArrayKeys(self::MIXED_CASES);
131132
$this->assertEqualsWithDelta($result, self::AFTER_SNAKE, self::MAX_DEPTH);
132133
}
133134

134135
/**
135-
* @test
136136
*/
137+
#[Test]
137138
public function keyCaseFiltersShouldProduceConsistentResults()
138139
{
139140
$result = Helpers::camelCaseArrayKeys(Helpers::snakeCaseArrayKeys(Helpers::camelCaseArrayKeys(Helpers::snakeCaseArrayKeys(self::MIXED_CASES))));

0 commit comments

Comments
 (0)