Skip to content

Commit 0832af0

Browse files
committedJun 20, 2023
Merge branch 'release/2.0.0' into main
2 parents e98734d + d0ab94f commit 0832af0

File tree

13 files changed

+80
-33
lines changed

13 files changed

+80
-33
lines changed
 

‎.github/workflows/tests.yml

+5-8
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ jobs:
1414
strategy:
1515
fail-fast: true
1616
matrix:
17-
php: [7.4, '8.0', 8.1]
18-
laravel: [8.76, 9]
19-
exclude:
20-
- php: 7.4
21-
laravel: 9
17+
php: [8.1, 8.2]
18+
laravel: [10]
2219

2320
steps:
2421
- name: Checkout Code
25-
uses: actions/checkout@v2
22+
uses: actions/checkout@v3
2623

2724
- name: Setup PHP
2825
uses: shivammathur/setup-php@v2
@@ -31,13 +28,13 @@ jobs:
3128
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
3229
tools: composer:v2
3330
coverage: none
34-
ini-values: error_reporting=E_ALL
31+
ini-values: error_reporting=E_ALL, zend.assertions=1
3532

3633
- name: Set Laravel Version
3734
run: composer require "laravel/framework:^${{ matrix.laravel }}" --no-update -n
3835

3936
- name: Install dependencies
40-
uses: nick-invision/retry@v1
37+
uses: nick-fields/retry@v2
4138
with:
4239
timeout_minutes: 5
4340
max_attempts: 5

‎CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file. This project adheres to
44
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
55

6+
## [2.0.0] - 2023-06-20
7+
8+
### Changed
9+
10+
- Upgraded to Laravel 10.
11+
- Minimum PHP version is now 8.1.
12+
- Use `assert()` to ensure the soft delete boolean driver receives the correct type of model.
13+
614
## [1.1.0] - 2022-09-14
715

816
### Added

‎composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
}
2424
],
2525
"require": {
26-
"php": "^7.4|^8.0",
27-
"illuminate/support": "^8.0|^9.0",
28-
"laravel-json-api/eloquent": "^1.0.1|^2.0",
29-
"tenantcloud/laravel-boolean-softdeletes": "^3.1|^4.0"
26+
"php": "^8.1",
27+
"illuminate/support": "^10.0",
28+
"laravel-json-api/eloquent": "^3.0",
29+
"tenantcloud/laravel-boolean-softdeletes": "^5.0"
3030
},
3131
"require-dev": {
32-
"orchestra/testbench": "^6.23|^7.0",
33-
"phpunit/phpunit": "^9.5.10"
32+
"orchestra/testbench": "^8.0",
33+
"phpunit/phpunit": "^9.6.9"
3434
},
3535
"autoload": {
3636
"psr-4": {
@@ -46,10 +46,10 @@
4646
},
4747
"extra": {
4848
"branch-alias": {
49-
"dev-develop": "1.x-dev"
49+
"dev-develop": "2.x-dev"
5050
}
5151
},
52-
"minimum-stability": "dev",
52+
"minimum-stability": "stable",
5353
"prefer-stable": true,
5454
"config": {
5555
"sort-packages": true

‎src/Drivers/SoftDeleteBooleanDriver.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2022 Cloud Creativity Limited
3+
* Copyright 2023 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -21,24 +21,23 @@
2121

2222
use Illuminate\Database\Eloquent\Builder;
2323
use Illuminate\Database\Eloquent\Model;
24-
use InvalidArgumentException;
2524
use LaravelJsonApi\Eloquent\Drivers\StandardDriver;
2625
use Webkid\LaravelBooleanSoftdeletes\SoftDeletesBoolean;
2726
use function boolval;
2827

2928
class SoftDeleteBooleanDriver extends StandardDriver
3029
{
31-
3230
/**
3331
* SoftDeleteDriver constructor.
3432
*
35-
* @param Model|SoftDeletesBoolean $model
33+
* @param Model&SoftDeletesBoolean $model
3634
*/
3735
public function __construct($model)
3836
{
39-
if (!in_array(SoftDeletesBoolean::class, class_uses_recursive($model), true)) {
40-
throw new InvalidArgumentException('Expecting a model that is boolean soft-deletable.');
41-
}
37+
assert(
38+
in_array(SoftDeletesBoolean::class, class_uses_recursive($model), true),
39+
'Expecting a model that is boolean soft-deletable.',
40+
);
4241

4342
parent::__construct($model);
4443
}
@@ -91,7 +90,7 @@ public function destroy(Model $model): bool
9190
}
9291

9392
/**
94-
* @param Model|SoftDeletesBoolean $model
93+
* @param Model&SoftDeletesBoolean $model
9594
* @return bool
9695
*/
9796
private function restore(Model $model): bool
@@ -102,7 +101,7 @@ private function restore(Model $model): bool
102101
/**
103102
* Will the hydration operation restore the model?
104103
*
105-
* @param Model|SoftDeletesBoolean $model
104+
* @param Model&SoftDeletesBoolean $model
106105
* @return bool
107106
*/
108107
private function willRestore(Model $model): bool
@@ -119,7 +118,7 @@ private function willRestore(Model $model): bool
119118
/**
120119
* Will the hydration operation result in the model being soft deleted?
121120
*
122-
* @param Model|SoftDeletesBoolean $model
121+
* @param Model&SoftDeletesBoolean $model
123122
* @return bool
124123
*/
125124
private function willSoftDelete(Model $model): bool

‎src/SoftDeletesBoolean.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2022 Cloud Creativity Limited
3+
* Copyright 2023 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

‎tests/app/Models/Post.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2022 Cloud Creativity Limited
3+
* Copyright 2023 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

‎tests/app/Schemas/PostSchema.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2022 Cloud Creativity Limited
3+
* Copyright 2023 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

‎tests/database/factories/PostFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2022 Cloud Creativity Limited
3+
* Copyright 2023 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

‎tests/database/migrations/2021_04_23_1032_create_post_table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2022 Cloud Creativity Limited
3+
* Copyright 2023 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

‎tests/lib/Acceptance/Test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2022 Cloud Creativity Limited
3+
* Copyright 2023 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

‎tests/lib/Acceptance/TestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2022 Cloud Creativity Limited
3+
* Copyright 2023 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

‎tests/lib/Unit/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/*
3+
* Copyright 2023 Cloud Creativity Limited
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
declare(strict_types=1);
19+
20+
namespace LaravelJsonApi\BooleanSoftDeletes\Tests\Unit\Drivers;
21+
22+
use Illuminate\Database\Eloquent\Model;
23+
use Illuminate\Database\Eloquent\SoftDeletes;
24+
use LaravelJsonApi\BooleanSoftDeletes\Drivers\SoftDeleteBooleanDriver;
25+
use PHPUnit\Framework\TestCase;
26+
27+
class SoftDeleteBooleanDriverTest extends TestCase
28+
{
29+
/**
30+
* @return void
31+
*/
32+
public function testModelMustHaveBooleanSoftDeletesTrait(): void
33+
{
34+
$model = new class extends Model {
35+
use SoftDeletes;
36+
};
37+
38+
$this->expectException(\AssertionError::class);
39+
$this->expectExceptionMessage('Expecting a model that is boolean soft-deletable.');
40+
41+
new SoftDeleteBooleanDriver($model);
42+
}
43+
}

0 commit comments

Comments
 (0)
Please sign in to comment.