Skip to content

Commit eff1fe2

Browse files
Merge pull request owen-it#489 from squiaios/patch-1
Laravel 5.8 support
2 parents 3108a17 + fd03d35 commit eff1fe2

File tree

11 files changed

+34
-49
lines changed

11 files changed

+34
-49
lines changed

.scrutinizer.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,10 @@ filter:
99

1010
build:
1111
nodes:
12-
php70:
13-
environment:
14-
php:
15-
version: 7.0.20
16-
tests:
17-
override:
18-
- php-scrutinizer-run
19-
-
20-
command: vendor/bin/phpunit --coverage-clover=coverage70
21-
coverage:
22-
file: coverage70
23-
format: php-clover
2412
php71:
2513
environment:
2614
php:
27-
version: 7.1.12
15+
version: 7.1.3
2816
tests:
2917
override:
3018
- php-scrutinizer-run

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ env:
55
language: php
66

77
php:
8-
- 7.0
98
- 7.1
109
- 7.2
1110

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,15 @@
3939
}
4040
],
4141
"require": {
42-
"php": ">=7.0.13",
43-
"illuminate/console": "5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*",
44-
"illuminate/database": "5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*",
45-
"illuminate/filesystem": "5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*"
42+
"php": ">=7.1.3",
43+
"illuminate/console": "^5.8",
44+
"illuminate/database": "^5.8",
45+
"illuminate/filesystem": "^5.8"
4646
},
4747
"require-dev": {
48-
"phpunit/phpunit": "^6.0",
48+
"phpunit/phpunit": "^7.5",
4949
"mockery/mockery": "^1.0",
50-
"orchestra/testbench": "^3.5",
51-
"orchestra/database": "^3.5"
50+
"orchestra/testbench": "^3.8"
5251
},
5352
"autoload": {
5453
"psr-4": {

phpunit.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
processIsolation="false"
1010
stopOnError="false"
1111
stopOnFailure="true"
12-
syntaxCheck="true"
1312
verbose="true"
1413
>
1514
<testsuites>

src/Auditable.php

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

55
use Illuminate\Database\Eloquent\Relations\MorphMany;
66
use Illuminate\Database\Eloquent\SoftDeletes;
7+
use Illuminate\Support\Arr;
78
use Illuminate\Support\Facades\App;
89
use Illuminate\Support\Facades\Config;
910
use OwenIt\Auditing\Contracts\AttributeEncoder;
@@ -93,7 +94,7 @@ protected function resolveAuditExclusions()
9394
}
9495

9596
// Valid attributes are all those that made it out of the exclusion array
96-
$attributes = array_except($this->attributes, $this->excludedAttributes);
97+
$attributes = Arr::except($this->attributes, $this->excludedAttributes);
9798

9899
foreach ($attributes as $attribute => $value) {
99100
// Apart from null, non scalar values will be excluded
@@ -152,8 +153,8 @@ protected function getUpdatedEventAttributes(): array
152153

153154
foreach ($this->getDirty() as $attribute => $value) {
154155
if ($this->isAttributeAuditable($attribute)) {
155-
$old[$attribute] = array_get($this->original, $attribute);
156-
$new[$attribute] = array_get($this->attributes, $attribute);
156+
$old[$attribute] = Arr::get($this->original, $attribute);
157+
$new[$attribute] = Arr::get($this->attributes, $attribute);
157158
}
158159
}
159160

src/AuditingServiceProvider.php

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

33
namespace OwenIt\Auditing;
44

5+
use Illuminate\Contracts\Support\DeferrableProvider;
56
use Illuminate\Support\ServiceProvider;
67
use OwenIt\Auditing\Console\AuditDriverMakeCommand;
78
use OwenIt\Auditing\Contracts\Auditor;
89

9-
class AuditingServiceProvider extends ServiceProvider
10+
class AuditingServiceProvider extends ServiceProvider implements DeferrableProvider
1011
{
11-
/**
12-
* {@inheritdoc}
13-
*/
14-
protected $defer = true;
15-
1612
/**
1713
* Bootstrap the service provider.
1814
*

src/Auditor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function execute(Auditable $model)
7070
$driver->prune($model);
7171
}
7272

73-
$this->app->make('events')->fire(
73+
$this->app->make('events')->dispatch(
7474
new Audited($model, $driver, $audit)
7575
);
7676
}

tests/AuditingTestCase.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace OwenIt\Auditing\Tests;
44

5-
use Orchestra\Database\ConsoleServiceProvider;
65
use Orchestra\Testbench\TestCase;
76
use OwenIt\Auditing\AuditingServiceProvider;
87
use OwenIt\Auditing\Resolvers\IpAddressResolver;
@@ -42,7 +41,7 @@ protected function getEnvironmentSetUp($app)
4241
/**
4342
* {@inheritdoc}
4443
*/
45-
public function setUp()
44+
public function setUp(): void
4645
{
4746
parent::setUp();
4847

@@ -57,7 +56,6 @@ protected function getPackageProviders($app)
5756
{
5857
return [
5958
AuditingServiceProvider::class,
60-
ConsoleServiceProvider::class,
6159
];
6260
}
6361
}

tests/Functional/CommandTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ public function itWillGenerateTheAuditDriver()
1616
$this->app->path()
1717
);
1818

19-
$this->assertSame(0, $this->artisan('make:audit-driver', [
20-
'name' => 'TestDriver',
21-
]));
19+
$this->assertInstanceOf(
20+
\Illuminate\Foundation\Testing\PendingCommand::class,
21+
$this->artisan('make:audit-driver', [
22+
'name' => 'TestDriver',
23+
]
24+
)
25+
);
2226

2327
$this->assertFileExists($driverFilePath);
2428

tests/Unit/AuditTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function itResolvesAuditData()
3636
'audit_event' => 'created',
3737
'audit_url' => 'console',
3838
'audit_ip_address' => '127.0.0.1',
39-
'audit_user_agent' => 'Symfony/3.X',
39+
'audit_user_agent' => 'Symfony',
4040
'audit_tags' => null,
4141
'audit_created_at' => $audit->created_at->toDateTimeString(),
4242
'audit_updated_at' => $audit->updated_at->toDateTimeString(),
@@ -83,7 +83,7 @@ public function itResolvesAuditDataIncludingUserAttributes()
8383
'audit_event' => 'created',
8484
'audit_url' => 'console',
8585
'audit_ip_address' => '127.0.0.1',
86-
'audit_user_agent' => 'Symfony/3.X',
86+
'audit_user_agent' => 'Symfony',
8787
'audit_tags' => null,
8888
'audit_created_at' => $audit->created_at->toDateTimeString(),
8989
'audit_updated_at' => $audit->updated_at->toDateTimeString(),
@@ -164,7 +164,7 @@ public function itReturnsAuditMetadataAsArray()
164164
'audit_event' => 'created',
165165
'audit_url' => 'console',
166166
'audit_ip_address' => '127.0.0.1',
167-
'audit_user_agent' => 'Symfony/3.X',
167+
'audit_user_agent' => 'Symfony',
168168
'audit_tags' => null,
169169
'audit_created_at' => $audit->created_at->toDateTimeString(),
170170
'audit_updated_at' => $audit->updated_at->toDateTimeString(),
@@ -197,7 +197,7 @@ public function itReturnsAuditMetadataIncludingUserAttributesAsArray()
197197
'audit_event' => 'created',
198198
'audit_url' => 'console',
199199
'audit_ip_address' => '127.0.0.1',
200-
'audit_user_agent' => 'Symfony/3.X',
200+
'audit_user_agent' => 'Symfony',
201201
'audit_tags' => null,
202202
'audit_created_at' => $audit->created_at->toDateTimeString(),
203203
'audit_updated_at' => $audit->updated_at->toDateTimeString(),
@@ -228,7 +228,7 @@ public function itReturnsAuditMetadataAsJsonString()
228228
"audit_event": "created",
229229
"audit_url": "console",
230230
"audit_ip_address": "127.0.0.1",
231-
"audit_user_agent": "Symfony\/3.X",
231+
"audit_user_agent": "Symfony",
232232
"audit_tags": null,
233233
"audit_created_at": "$audit->created_at",
234234
"audit_updated_at": "$audit->updated_at",
@@ -265,7 +265,7 @@ public function itReturnsAuditMetadataIncludingUserAttributesAsJsonString()
265265
"audit_event": "created",
266266
"audit_url": "console",
267267
"audit_ip_address": "127.0.0.1",
268-
"audit_user_agent": "Symfony\/3.X",
268+
"audit_user_agent": "Symfony",
269269
"audit_tags": null,
270270
"audit_created_at": "$audit->created_at",
271271
"audit_updated_at": "$audit->updated_at",

0 commit comments

Comments
 (0)