Skip to content

Commit 18b3ebb

Browse files
Add support for Laravel 8 (#30)
With this PR we're dropping supports for lower versions of Laravel
1 parent 1f065b3 commit 18b3ebb

31 files changed

+253
-146
lines changed

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ matrix:
66
fast_finish: true
77
include:
88
- php: 7.3
9-
env: LARAVEL=^6.0 ORCHESTRA=^4.0
9+
env: LARAVEL=^8.0 ORCHESTRA=^6.0
1010
- php: 7.4
11-
env: LARAVEL=^6.0 ORCHESTRA=^4.0
12-
- php: 7.3
13-
env: LARAVEL=^7.0 ORCHESTRA=^5.0
14-
- php: 7.4
15-
env: LARAVEL=^7.0 ORCHESTRA=^5.0 COVERAGE=1
11+
env: LARAVEL=^8.0 ORCHESTRA=^6.0 COVERAGE=1
1612

1713
allow_failures:
1814
- env: COVERAGE=1

composer.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@
2222
},
2323
"require": {
2424
"php": "^7.3",
25-
"illuminate/database": "^6.0|^7.0",
26-
"illuminate/support": "^6.0|^7.0"
25+
"illuminate/database": "^8.0",
26+
"illuminate/support": "^8.0"
2727
},
2828
"require-dev": {
2929
"ekino/phpstan-banned-code": "^0.3.1",
30-
"mockery/mockery": "~1.0",
31-
"orchestra/database": "~4.0|~5.0",
32-
"orchestra/testbench": "~4.0|~5.0",
33-
"phpmd/phpmd": "^2.8",
34-
"phpstan/phpstan": "^0.11|^0.12",
35-
"phpstan/phpstan-deprecation-rules": "^0.11|^0.12",
36-
"phpstan/phpstan-strict-rules": "^0.11|^0.12",
37-
"phpunit/phpunit": "^9.0 || ^8.0",
38-
"sebastian/phpcpd": "^5.0"
30+
"mockery/mockery": "^1.3",
31+
"orchestra/database": "~6.0",
32+
"orchestra/testbench": "~6.0",
33+
"phpmd/phpmd": "^2.9",
34+
"phpstan/phpstan": "^0.12",
35+
"phpstan/phpstan-deprecation-rules": "^0.12",
36+
"phpstan/phpstan-strict-rules": "^0.12",
37+
"phpunit/phpunit": "^9.3",
38+
"sebastian/phpcpd": "^6.0"
3939
},
4040
"config": {
4141
"sort-packages": true
@@ -50,7 +50,8 @@
5050
},
5151
"autoload-dev": {
5252
"psr-4": {
53-
"RichanFongdasen\\EloquentBlameableTest\\": "tests/"
53+
"RichanFongdasen\\EloquentBlameableTest\\": "tests/",
54+
"Database\\Factories\\": "tests/Supports/Factories/"
5455
}
5556
},
5657
"extra": {

phpunit.xml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
bootstrap="vendor/autoload.php"
6-
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="true">
12-
<testsuites>
13-
<testsuite name="Blameable Test Suite">
14-
<directory suffix="Tests.php">./tests/</directory>
15-
</testsuite>
16-
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory suffix=".php">src/</directory>
20-
</whitelist>
21-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="Blameable Test Suite">
10+
<directory suffix="Tests.php">./tests/</directory>
11+
</testsuite>
12+
</testsuites>
2213
</phpunit>

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ $ composer require richan-fongdasen/eloquent-blameable
3737
| 5.5.x - 5.8.x | 1.3.x |
3838
| 6.x | 1.4.x |
3939
| 7.x | 1.5.x |
40+
| 8.x | 1.6.x |
4041

4142
> If you are using Laravel version 5.5+ then you can skip registering the service provider in your Laravel application.
4243

tests/ObservedModelTests.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ObservedModelTests extends TestCase
1313
public function it_works_perfectly_on_creating_a_new_post()
1414
{
1515
$this->impersonateUser();
16-
$post = factory(Post::class)->create();
16+
$post = Post::factory()->create();
1717

1818
$this->assertFalse($post->isDirty('created_by'));
1919
$this->assertFalse($post->isDirty('updated_by'));
@@ -25,7 +25,7 @@ public function it_works_perfectly_on_creating_a_new_post()
2525
public function it_works_perfectly_on_updating_existing_post()
2626
{
2727
$this->impersonateUser();
28-
$post = factory(Post::class)->create();
28+
$post = Post::factory()->create();
2929

3030
$this->impersonateOtherUser();
3131
$post->setAttribute('title', 'Another Title');
@@ -41,7 +41,7 @@ public function it_works_perfectly_on_updating_existing_post()
4141
public function it_works_perfectly_on_deleting_post1()
4242
{
4343
$this->impersonateUser();
44-
$post = factory(Post::class)->create();
44+
$post = Post::factory()->create();
4545

4646
$post->delete();
4747
$deletedPost = Post::onlyTrashed()->where('id', $post->getKey())->first();
@@ -53,7 +53,7 @@ public function it_works_perfectly_on_deleting_post1()
5353
public function it_works_perfectly_on_deleting_post2()
5454
{
5555
$this->impersonateUser();
56-
$post = factory(Post::class)->create();
56+
$post = Post::factory()->create();
5757

5858
$this->impersonateOtherUser();
5959
$post->delete();
@@ -67,7 +67,7 @@ public function it_works_perfectly_on_deleting_post2()
6767
public function it_works_perfectly_on_restoring_deleted_post()
6868
{
6969
$this->impersonateUser();
70-
$post = factory(Post::class)->create();
70+
$post = Post::factory()->create();
7171

7272
$this->impersonateOtherUser();
7373
$post->delete();
@@ -81,7 +81,7 @@ public function it_works_perfectly_on_restoring_deleted_post()
8181
public function it_works_perfectly_on_creating_a_new_comment()
8282
{
8383
$this->impersonateUser();
84-
$comment = factory(Comment::class)->create([
84+
$comment = Comment::factory()->create([
8585
'post_id' => 100
8686
]);
8787

@@ -95,8 +95,8 @@ public function it_works_perfectly_on_creating_a_new_comment()
9595
public function it_works_perfectly_on_updating_existing_comment()
9696
{
9797
$this->impersonateUser();
98-
$post = factory(Post::class)->create();
99-
$comment = factory(Comment::class)->create([
98+
$post = Post::factory()->create();
99+
$comment = Comment::factory()->create([
100100
'post_id' => $post->getKey()
101101
]);
102102

@@ -119,7 +119,7 @@ public function it_works_perfectly_on_updating_existing_comment()
119119
public function it_works_perfectly_on_deleting_comment1()
120120
{
121121
$this->impersonateUser();
122-
$comment = factory(Comment::class)->create([
122+
$comment = Comment::factory()->create([
123123
'post_id' => 100
124124
]);
125125

@@ -133,7 +133,7 @@ public function it_works_perfectly_on_deleting_comment1()
133133
public function it_works_perfectly_on_deleting_comment2()
134134
{
135135
$this->impersonateUser();
136-
$comment = factory(Comment::class)->create([
136+
$comment = Comment::factory()->create([
137137
'post_id' => 100
138138
]);
139139

@@ -149,7 +149,7 @@ public function it_works_perfectly_on_deleting_comment2()
149149
public function it_works_perfectly_on_restoring_deleted_comment()
150150
{
151151
$this->impersonateUser();
152-
$comment = factory(Comment::class)->create([
152+
$comment = Comment::factory()->create([
153153
'post_id' => 100
154154
]);
155155

@@ -188,7 +188,7 @@ public function it_works_perfectly_on_creating_a_new_user2()
188188
public function it_works_perfectly_on_updating_existing_user()
189189
{
190190
$this->impersonateUser();
191-
$user = factory(User::class)->create();
191+
$user = User::factory()->create();
192192

193193
$this->impersonateOtherUser();
194194
$user->setAttribute('email', 'another@email.com');
@@ -204,7 +204,7 @@ public function it_works_perfectly_on_updating_existing_user()
204204
public function it_works_perfectly_on_deleting_user1()
205205
{
206206
$this->impersonateUser();
207-
$user = factory(User::class)->create();
207+
$user = User::factory()->create();
208208

209209
$user->delete();
210210
$deletedUser = User::onlyTrashed()->where('id', $user->getKey())->first();
@@ -216,7 +216,7 @@ public function it_works_perfectly_on_deleting_user1()
216216
public function it_works_perfectly_on_deleting_user2()
217217
{
218218
$this->impersonateUser();
219-
$user = factory(User::class)->create();
219+
$user = User::factory()->create();
220220

221221
$this->impersonateOtherUser();
222222
$user->delete();
@@ -230,7 +230,7 @@ public function it_works_perfectly_on_deleting_user2()
230230
public function it_works_perfectly_on_restoring_deleted_user()
231231
{
232232
$this->impersonateUser();
233-
$user = factory(User::class)->create();
233+
$user = User::factory()->create();
234234

235235
$this->impersonateOtherUser();
236236
$user->delete();
@@ -243,7 +243,7 @@ public function it_works_perfectly_on_restoring_deleted_user()
243243
/** @test */
244244
public function it_will_set_null_creator_and_null_updater_on_unauthenticated_user()
245245
{
246-
$post = factory(Post::class)->create();
246+
$post = Post::factory()->create();
247247

248248
$this->assertNull($post->getAttribute('created_by'));
249249
$this->assertNull($post->getAttribute('updated_by'));
@@ -254,7 +254,7 @@ public function it_wont_cause_any_error_when_deleting_model_without_soft_deletes
254254
{
255255
$this->impersonateAdmin();
256256

257-
$news = factory(News::class)->create();
257+
$news = News::factory()->create();
258258
$news->delete();
259259
$news->fresh();
260260

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use Illuminate\Support\Str;
7+
use RichanFongdasen\EloquentBlameableTest\Supports\Models\Admin;
8+
9+
class AdminFactory extends Factory
10+
{
11+
/**
12+
* The name of the factory's corresponding model.
13+
*
14+
* @var string
15+
*/
16+
protected $model = Admin::class;
17+
18+
/**
19+
* Define the model's default state.
20+
*
21+
* @return array
22+
*/
23+
public function definition()
24+
{
25+
return [
26+
'name' => $this->faker->name,
27+
'email' => $this->faker->email,
28+
'password' => bcrypt(Str::random(12)),
29+
'remember_token' => Str::random(12),
30+
];
31+
}
32+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use RichanFongdasen\EloquentBlameableTest\Supports\Models\Article;
7+
8+
class ArticleFactory extends Factory
9+
{
10+
/**
11+
* The name of the factory's corresponding model.
12+
*
13+
* @var string
14+
*/
15+
protected $model = Article::class;
16+
17+
/**
18+
* Define the model's default state.
19+
*
20+
* @return array
21+
*/
22+
public function definition()
23+
{
24+
return [
25+
'title' => $this->faker->sentence,
26+
'content' => $this->faker->paragraph,
27+
];
28+
}
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use RichanFongdasen\EloquentBlameableTest\Supports\Models\Comment;
7+
8+
class CommentFactory extends Factory
9+
{
10+
/**
11+
* The name of the factory's corresponding model.
12+
*
13+
* @var string
14+
*/
15+
protected $model = Comment::class;
16+
17+
/**
18+
* Define the model's default state.
19+
*
20+
* @return array
21+
*/
22+
public function definition()
23+
{
24+
return [
25+
'content' => $this->faker->paragraph,
26+
];
27+
}
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use RichanFongdasen\EloquentBlameableTest\Supports\Models\News;
7+
8+
class NewsFactory extends Factory
9+
{
10+
/**
11+
* The name of the factory's corresponding model.
12+
*
13+
* @var string
14+
*/
15+
protected $model = News::class;
16+
17+
/**
18+
* Define the model's default state.
19+
*
20+
* @return array
21+
*/
22+
public function definition()
23+
{
24+
return [
25+
'title' => $this->faker->sentence,
26+
'content' => $this->faker->paragraph,
27+
];
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use RichanFongdasen\EloquentBlameableTest\Supports\Models\Post;
7+
8+
class PostFactory extends Factory
9+
{
10+
/**
11+
* The name of the factory's corresponding model.
12+
*
13+
* @var string
14+
*/
15+
protected $model = Post::class;
16+
17+
/**
18+
* Define the model's default state.
19+
*
20+
* @return array
21+
*/
22+
public function definition()
23+
{
24+
return [
25+
'title' => $this->faker->sentence,
26+
'content' => $this->faker->paragraph,
27+
];
28+
}
29+
}

0 commit comments

Comments
 (0)