Skip to content

Commit 31bed27

Browse files
committed
Add support for Laravel 11
1 parent 2e2c525 commit 31bed27

12 files changed

+68
-58
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
],
1313
"require": {
1414
"php": "^8.0",
15-
"illuminate/database": "^10.13.2",
16-
"illuminate/http": "^10.13.2",
17-
"illuminate/routing": "^10.13.2",
18-
"illuminate/support": "^10.13.2"
15+
"illuminate/database": "^11.0",
16+
"illuminate/http": "^11.0",
17+
"illuminate/routing": "^11.0",
18+
"illuminate/support": "^11.0"
1919
},
2020
"require-dev": {
2121
"laravel/sail": "^1.26",
22-
"orchestra/testbench": "^8.15"
22+
"orchestra/testbench": "^9.0"
2323
},
2424
"autoload": {
2525
"psr-4": {

src/SyncService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function pull(Request $request): JsonResponse
2727

2828
$changes = [];
2929

30-
if ($lastPulledAt === 'null') {
30+
if ($lastPulledAt === null) {
3131
foreach ($this->models as $name => $class) {
3232
$changes[$name] = [
3333
'created' => (new $class)::watermelon()

tests/Feature/CustomWatermelonIDModelPullTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\Config;
88
use NathanHeffley\LaravelWatermelon\Tests\models\CustomTask as Task;
99
use NathanHeffley\LaravelWatermelon\Tests\TestCase;
10+
use PHPUnit\Framework\Attributes\Test;
1011

1112
class CustomWatermelonIDModelPullTest extends TestCase
1213
{
@@ -25,7 +26,7 @@ public function setUp(): void
2526
]);
2627
}
2728

28-
/** @test */
29+
#[Test]
2930
public function it_can_respond_to_pull_requests_with_no_data_and_no_last_pulled_at_timestamp(): void
3031
{
3132
$response = $this->json('GET', '/sync');
@@ -42,7 +43,7 @@ public function it_can_respond_to_pull_requests_with_no_data_and_no_last_pulled_
4243
]);
4344
}
4445

45-
/** @test */
46+
#[Test]
4647
public function it_can_respond_to_pull_requests_with_no_data_and_a_null_last_pulled_at_timestamp(): void
4748
{
4849
$response = $this->json('GET', '/sync?last_pulled_at=null');
@@ -59,7 +60,7 @@ public function it_can_respond_to_pull_requests_with_no_data_and_a_null_last_pul
5960
]);
6061
}
6162

62-
/** @test */
63+
#[Test]
6364
public function it_can_respond_to_pull_requests_with_no_data_and_a_zero_last_pulled_at_timestamp(): void
6465
{
6566
$response = $this->json('GET', '/sync?last_pulled_at=0');
@@ -76,7 +77,7 @@ public function it_can_respond_to_pull_requests_with_no_data_and_a_zero_last_pul
7677
]);
7778
}
7879

79-
/** @test */
80+
#[Test]
8081
public function it_can_respond_to_pull_requests_with_no_changes_and_a_last_pulled_at_timestamp(): void
8182
{
8283
$lastPulledAt = now()->subMinutes(10)->timestamp;
@@ -94,7 +95,7 @@ public function it_can_respond_to_pull_requests_with_no_changes_and_a_last_pulle
9495
]);
9596
}
9697

97-
/** @test */
98+
#[Test]
9899
public function it_can_respond_to_pull_requests_with_data_and_no_last_pulled_at_timestamp(): void
99100
{
100101
Task::query()->create([
@@ -141,7 +142,7 @@ public function it_can_respond_to_pull_requests_with_data_and_no_last_pulled_at_
141142
]);
142143
}
143144

144-
/** @test */
145+
#[Test]
145146
public function it_can_respond_to_pull_requests_with_data_and_a_null_last_pulled_at_timestamp(): void
146147
{
147148
Task::query()->create([
@@ -188,7 +189,7 @@ public function it_can_respond_to_pull_requests_with_data_and_a_null_last_pulled
188189
]);
189190
}
190191

191-
/** @test */
192+
#[Test]
192193
public function it_can_respond_to_pull_requests_with_data_and_a_zero_last_pulled_at_timestamp(): void
193194
{
194195
Task::query()->create([
@@ -235,7 +236,7 @@ public function it_can_respond_to_pull_requests_with_data_and_a_zero_last_pulled
235236
]);
236237
}
237238

238-
/** @test */
239+
#[Test]
239240
public function it_can_respond_to_pull_requests_with_data_and_a_last_pulled_at_timestamp(): void
240241
{
241242
Task::query()->create([
@@ -298,7 +299,7 @@ public function it_can_respond_to_pull_requests_with_data_and_a_last_pulled_at_t
298299
]);
299300
}
300301

301-
/** @test */
302+
#[Test]
302303
public function it_can_respond_to_pull_requests_with_lots_of_deleted_records_and_a_last_pulled_at_timestamp(): void
303304
{
304305
Task::query()->create([

tests/Feature/CustomWatermelonIDModelPushTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\Config;
88
use NathanHeffley\LaravelWatermelon\Tests\models\CustomTask as Task;
99
use NathanHeffley\LaravelWatermelon\Tests\TestCase;
10+
use PHPUnit\Framework\Attributes\Test;
1011

1112
class CustomWatermelonIDModelPushTest extends TestCase
1213
{
@@ -25,7 +26,7 @@ public function setUp(): void
2526
]);
2627
}
2728

28-
/** @test */
29+
#[Test]
2930
public function it_ignores_changes_for_models_not_in_the_watermelon_models_config_array(): void
3031
{
3132
$response = $this->json('POST', '/sync', [
@@ -48,7 +49,7 @@ public function it_ignores_changes_for_models_not_in_the_watermelon_models_confi
4849
$response->assertNoContent();
4950
}
5051

51-
/** @test */
52+
#[Test]
5253
public function it_persists_push_request_changes(): void
5354
{
5455
$firstTask = Task::query()->create([
@@ -98,7 +99,7 @@ public function it_persists_push_request_changes(): void
9899
]);
99100
}
100101

101-
/** @test */
102+
#[Test]
102103
public function it_updates_the_record_if_there_is_an_attempt_to_create_an_existing_record(): void
103104
{
104105
Task::query()->create([
@@ -136,7 +137,7 @@ public function it_updates_the_record_if_there_is_an_attempt_to_create_an_existi
136137
]);
137138
}
138139

139-
/** @test */
140+
#[Test]
140141
public function it_creates_a_record_if_there_is_an_attempt_to_update_a_non_existent_record(): void
141142
{
142143
$response = $this->json('POST', '/sync', [
@@ -164,7 +165,7 @@ public function it_creates_a_record_if_there_is_an_attempt_to_update_a_non_exist
164165
]);
165166
}
166167

167-
/** @test */
168+
#[Test]
168169
public function it_does_not_throw_an_error_if_there_is_an_attempt_to_delete_an_already_deleted_record(): void
169170
{
170171
$deletedAt = now()->subMinute();
@@ -188,7 +189,7 @@ public function it_does_not_throw_an_error_if_there_is_an_attempt_to_delete_an_a
188189
$this->assertEquals($deletedAt, $task->fresh()->deleted_at);
189190
}
190191

191-
/** @test */
192+
#[Test]
192193
public function it_rolls_back_push_request_changes_if_there_is_an_attempt_to_update_a_deleted_record(): void
193194
{
194195
Task::query()->create([

tests/Feature/ModelAuthorizationTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\Config;
88
use NathanHeffley\LaravelWatermelon\Tests\models\TaskScoped;
99
use NathanHeffley\LaravelWatermelon\Tests\TestCase;
10+
use PHPUnit\Framework\Attributes\Test;
1011

1112
class ModelAuthorizationTest extends TestCase
1213
{
@@ -23,7 +24,7 @@ public function setUp(): void
2324
]);
2425
}
2526

26-
/** @test */
27+
#[Test]
2728
public function it_can_apply_a_models_watermelon_scope_with_no_last_pulled_at_timestamp(): void
2829
{
2930
TaskScoped::query()->create([
@@ -69,7 +70,7 @@ public function it_can_apply_a_models_watermelon_scope_with_no_last_pulled_at_ti
6970
]);
7071
}
7172

72-
/** @test */
73+
#[Test]
7374
public function it_can_apply_a_models_watermelon_scope_with_a_last_pulled_at_timestamp(): void
7475
{
7576
TaskScoped::query()->create([
@@ -116,7 +117,7 @@ public function it_can_apply_a_models_watermelon_scope_with_a_last_pulled_at_tim
116117
]);
117118
}
118119

119-
/** @test */
120+
#[Test]
120121
public function it_throws_an_exception_and_rolls_back_changes_when_trying_to_update_a_model_restricted_by_watermelon_scope(): void
121122
{
122123
TaskScoped::query()->create([
@@ -172,7 +173,7 @@ public function it_throws_an_exception_and_rolls_back_changes_when_trying_to_upd
172173
]);
173174
}
174175

175-
/** @test */
176+
#[Test]
176177
public function it_does_not_throw_an_error_but_does_not_delete_a_model_restricted_by_watermelon_scope(): void
177178
{
178179
TaskScoped::query()->create([

tests/Feature/MultipleModelPullTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use NathanHeffley\LaravelWatermelon\Tests\models\Project;
99
use NathanHeffley\LaravelWatermelon\Tests\models\Task;
1010
use NathanHeffley\LaravelWatermelon\Tests\TestCase;
11+
use PHPUnit\Framework\Attributes\Test;
1112

1213
class MultipleModelPullTest extends TestCase
1314
{
@@ -25,7 +26,7 @@ public function setUp(): void
2526
]);
2627
}
2728

28-
/** @test */
29+
#[Test]
2930
public function it_can_respond_to_pull_requests_for_multiple_models_without_a_last_pulled_at_timestamp(): void
3031
{
3132
Task::query()->create([
@@ -68,7 +69,7 @@ public function it_can_respond_to_pull_requests_for_multiple_models_without_a_la
6869
]);
6970
}
7071

71-
/** @test */
72+
#[Test]
7273
public function it_can_respond_to_pull_requests_for_multiple_models_with_a_null_last_pulled_at_timestamp(): void
7374
{
7475
Task::query()->create([
@@ -111,7 +112,7 @@ public function it_can_respond_to_pull_requests_for_multiple_models_with_a_null_
111112
]);
112113
}
113114

114-
/** @test */
115+
#[Test]
115116
public function it_can_respond_to_pull_requests_for_multiple_models_with_a_zero_last_pulled_at_timestamp(): void
116117
{
117118
Task::query()->create([
@@ -154,7 +155,7 @@ public function it_can_respond_to_pull_requests_for_multiple_models_with_a_zero_
154155
]);
155156
}
156157

157-
/** @test */
158+
#[Test]
158159
public function it_can_respond_to_pull_requests_for_multiple_models_with_a_last_pulled_at_timestamp(): void
159160
{
160161
Task::query()->create([

tests/Feature/MultipleModelPushTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use NathanHeffley\LaravelWatermelon\Tests\models\Project;
99
use NathanHeffley\LaravelWatermelon\Tests\models\Task;
1010
use NathanHeffley\LaravelWatermelon\Tests\TestCase;
11+
use PHPUnit\Framework\Attributes\Test;
1112

1213
class MultipleModelPushTest extends TestCase
1314
{
@@ -25,7 +26,7 @@ public function setUp(): void
2526
]);
2627
}
2728

28-
/** @test */
29+
#[Test]
2930
public function it_persists_push_requests_for_multiple_models(): void
3031
{
3132
$firstTask = Task::query()->create([
@@ -108,7 +109,7 @@ public function it_persists_push_requests_for_multiple_models(): void
108109
]);
109110
}
110111

111-
/** @test */
112+
#[Test]
112113
public function it_rolls_back_push_request_changes_for_all_models_when_an_error_is_thrown_for_one_model(): void
113114
{
114115
Task::query()->create([
@@ -189,7 +190,7 @@ public function it_rolls_back_push_request_changes_for_all_models_when_an_error_
189190
]);
190191
}
191192

192-
/** @test */
193+
#[Test]
193194
public function it_persists_push_requests_even_when_one_model_of_many_is_missing(): void
194195
{
195196
$firstTask = Task::query()->create([
@@ -239,7 +240,7 @@ public function it_persists_push_requests_even_when_one_model_of_many_is_missing
239240
]);
240241
}
241242

242-
/** @test */
243+
#[Test]
243244
public function it_persists_push_requests_even_when_an_unknown_model_is_encountered_among_many(): void
244245
{
245246
$firstTask = Task::query()->create([

tests/Feature/NoModelPullTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Support\Carbon;
77
use Illuminate\Support\Facades\Config;
88
use NathanHeffley\LaravelWatermelon\Tests\TestCase;
9+
use PHPUnit\Framework\Attributes\Test;
910

1011
class NoModelPullTest extends TestCase
1112
{
@@ -20,7 +21,7 @@ public function setUp(): void
2021
Config::set('watermelon.models', []);
2122
}
2223

23-
/** @test */
24+
#[Test]
2425
public function it_can_respond_to_pull_requests_without_models_and_no_last_pulled_at(): void
2526
{
2627
$response = $this->json('GET', '/sync');
@@ -31,7 +32,7 @@ public function it_can_respond_to_pull_requests_without_models_and_no_last_pulle
3132
]);
3233
}
3334

34-
/** @test */
35+
#[Test]
3536
public function it_can_respond_to_pull_requests_without_models_and_null_last_pulled_at(): void
3637
{
3738
$response = $this->json('GET', '/sync?last_pulled_at=null');
@@ -42,7 +43,7 @@ public function it_can_respond_to_pull_requests_without_models_and_null_last_pul
4243
]);
4344
}
4445

45-
/** @test */
46+
#[Test]
4647
public function it_can_respond_to_pull_requests_without_models_and_zero_last_pulled_at(): void
4748
{
4849
$response = $this->json('GET', '/sync?last_pulled_at=0');
@@ -53,7 +54,7 @@ public function it_can_respond_to_pull_requests_without_models_and_zero_last_pul
5354
]);
5455
}
5556

56-
/** @test */
57+
#[Test]
5758
public function it_can_respond_to_pull_requests_without_models_and_last_pulled_at(): void
5859
{
5960
$lastPulledAt = now()->subMinutes(10)->timestamp;

tests/Feature/NoModelPushTest.php

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

55
use Illuminate\Support\Facades\Config;
66
use NathanHeffley\LaravelWatermelon\Tests\TestCase;
7+
use PHPUnit\Framework\Attributes\Test;
78

89
class NoModelPushTest extends TestCase
910
{
@@ -14,14 +15,14 @@ public function setUp(): void
1415
Config::set('watermelon.models', []);
1516
}
1617

17-
/** @test */
18+
#[Test]
1819
public function it_can_respond_to_push_requests_with_no_models_and_no_data(): void
1920
{
2021
$response = $this->json('POST', '/sync');
2122
$response->assertNoContent();
2223
}
2324

24-
/** @test */
25+
#[Test]
2526
public function it_can_respond_to_push_requests_with_no_models_and_unknown_data(): void
2627
{
2728
$response = $this->json('POST', '/sync', [

0 commit comments

Comments
 (0)