Skip to content

Commit

Permalink
Merge pull request #1 from owen-it/master
Browse files Browse the repository at this point in the history
Sync with upstream
  • Loading branch information
specialtactics authored Mar 3, 2019
2 parents 3108a17 + eff1fe2 commit 3d16642
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 49 deletions.
14 changes: 1 addition & 13 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,10 @@ filter:

build:
nodes:
php70:
environment:
php:
version: 7.0.20
tests:
override:
- php-scrutinizer-run
-
command: vendor/bin/phpunit --coverage-clover=coverage70
coverage:
file: coverage70
format: php-clover
php71:
environment:
php:
version: 7.1.12
version: 7.1.3
tests:
override:
- php-scrutinizer-run
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ env:
language: php

php:
- 7.0
- 7.1
- 7.2

Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@
}
],
"require": {
"php": ">=7.0.13",
"illuminate/console": "5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*",
"illuminate/database": "5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*",
"illuminate/filesystem": "5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*"
"php": ">=7.1.3",
"illuminate/console": "^5.8",
"illuminate/database": "^5.8",
"illuminate/filesystem": "^5.8"
},
"require-dev": {
"phpunit/phpunit": "^6.0",
"phpunit/phpunit": "^7.5",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^3.5",
"orchestra/database": "^3.5"
"orchestra/testbench": "^3.8"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
processIsolation="false"
stopOnError="false"
stopOnFailure="true"
syntaxCheck="true"
verbose="true"
>
<testsuites>
Expand Down
7 changes: 4 additions & 3 deletions src/Auditable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
use OwenIt\Auditing\Contracts\AttributeEncoder;
Expand Down Expand Up @@ -93,7 +94,7 @@ protected function resolveAuditExclusions()
}

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

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

foreach ($this->getDirty() as $attribute => $value) {
if ($this->isAttributeAuditable($attribute)) {
$old[$attribute] = array_get($this->original, $attribute);
$new[$attribute] = array_get($this->attributes, $attribute);
$old[$attribute] = Arr::get($this->original, $attribute);
$new[$attribute] = Arr::get($this->attributes, $attribute);
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/AuditingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

namespace OwenIt\Auditing;

use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
use OwenIt\Auditing\Console\AuditDriverMakeCommand;
use OwenIt\Auditing\Contracts\Auditor;

class AuditingServiceProvider extends ServiceProvider
class AuditingServiceProvider extends ServiceProvider implements DeferrableProvider
{
/**
* {@inheritdoc}
*/
protected $defer = true;

/**
* Bootstrap the service provider.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Auditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function execute(Auditable $model)
$driver->prune($model);
}

$this->app->make('events')->fire(
$this->app->make('events')->dispatch(
new Audited($model, $driver, $audit)
);
}
Expand Down
4 changes: 1 addition & 3 deletions tests/AuditingTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace OwenIt\Auditing\Tests;

use Orchestra\Database\ConsoleServiceProvider;
use Orchestra\Testbench\TestCase;
use OwenIt\Auditing\AuditingServiceProvider;
use OwenIt\Auditing\Resolvers\IpAddressResolver;
Expand Down Expand Up @@ -42,7 +41,7 @@ protected function getEnvironmentSetUp($app)
/**
* {@inheritdoc}
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -57,7 +56,6 @@ protected function getPackageProviders($app)
{
return [
AuditingServiceProvider::class,
ConsoleServiceProvider::class,
];
}
}
10 changes: 7 additions & 3 deletions tests/Functional/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ public function itWillGenerateTheAuditDriver()
$this->app->path()
);

$this->assertSame(0, $this->artisan('make:audit-driver', [
'name' => 'TestDriver',
]));
$this->assertInstanceOf(
\Illuminate\Foundation\Testing\PendingCommand::class,
$this->artisan('make:audit-driver', [
'name' => 'TestDriver',
]
)
);

$this->assertFileExists($driverFilePath);

Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/AuditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function itResolvesAuditData()
'audit_event' => 'created',
'audit_url' => 'console',
'audit_ip_address' => '127.0.0.1',
'audit_user_agent' => 'Symfony/3.X',
'audit_user_agent' => 'Symfony',
'audit_tags' => null,
'audit_created_at' => $audit->created_at->toDateTimeString(),
'audit_updated_at' => $audit->updated_at->toDateTimeString(),
Expand Down Expand Up @@ -83,7 +83,7 @@ public function itResolvesAuditDataIncludingUserAttributes()
'audit_event' => 'created',
'audit_url' => 'console',
'audit_ip_address' => '127.0.0.1',
'audit_user_agent' => 'Symfony/3.X',
'audit_user_agent' => 'Symfony',
'audit_tags' => null,
'audit_created_at' => $audit->created_at->toDateTimeString(),
'audit_updated_at' => $audit->updated_at->toDateTimeString(),
Expand Down Expand Up @@ -164,7 +164,7 @@ public function itReturnsAuditMetadataAsArray()
'audit_event' => 'created',
'audit_url' => 'console',
'audit_ip_address' => '127.0.0.1',
'audit_user_agent' => 'Symfony/3.X',
'audit_user_agent' => 'Symfony',
'audit_tags' => null,
'audit_created_at' => $audit->created_at->toDateTimeString(),
'audit_updated_at' => $audit->updated_at->toDateTimeString(),
Expand Down Expand Up @@ -197,7 +197,7 @@ public function itReturnsAuditMetadataIncludingUserAttributesAsArray()
'audit_event' => 'created',
'audit_url' => 'console',
'audit_ip_address' => '127.0.0.1',
'audit_user_agent' => 'Symfony/3.X',
'audit_user_agent' => 'Symfony',
'audit_tags' => null,
'audit_created_at' => $audit->created_at->toDateTimeString(),
'audit_updated_at' => $audit->updated_at->toDateTimeString(),
Expand Down Expand Up @@ -228,7 +228,7 @@ public function itReturnsAuditMetadataAsJsonString()
"audit_event": "created",
"audit_url": "console",
"audit_ip_address": "127.0.0.1",
"audit_user_agent": "Symfony\/3.X",
"audit_user_agent": "Symfony",
"audit_tags": null,
"audit_created_at": "$audit->created_at",
"audit_updated_at": "$audit->updated_at",
Expand Down Expand Up @@ -265,7 +265,7 @@ public function itReturnsAuditMetadataIncludingUserAttributesAsJsonString()
"audit_event": "created",
"audit_url": "console",
"audit_ip_address": "127.0.0.1",
"audit_user_agent": "Symfony\/3.X",
"audit_user_agent": "Symfony",
"audit_tags": null,
"audit_created_at": "$audit->created_at",
"audit_updated_at": "$audit->updated_at",
Expand Down
11 changes: 6 additions & 5 deletions tests/Unit/AuditableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Str;
use OwenIt\Auditing\Contracts\Auditable;
use OwenIt\Auditing\Encoders\Base64Encoder;
use OwenIt\Auditing\Exceptions\AuditableTransitionException;
Expand All @@ -21,7 +22,7 @@ class AuditableTest extends AuditingTestCase
/**
* {@inheritdoc}
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -395,7 +396,7 @@ public function itReturnsTheAuditData()
'user_type' => null,
'url' => 'console',
'ip_address' => '127.0.0.1',
'user_agent' => 'Symfony/3.X',
'user_agent' => 'Symfony',
'tags' => null,
], $auditData, true);
}
Expand Down Expand Up @@ -454,7 +455,7 @@ public function itReturnsTheAuditDataIncludingUserAttributes(
'user_type' => $type,
'url' => 'console',
'ip_address' => '127.0.0.1',
'user_agent' => 'Symfony/3.X',
'user_agent' => 'Symfony',
'tags' => null,
], $auditData, true);
}
Expand Down Expand Up @@ -534,7 +535,7 @@ public function itExcludesAttributesFromTheAuditDataWhenInStrictMode()
'user_type' => null,
'url' => 'console',
'ip_address' => '127.0.0.1',
'user_agent' => 'Symfony/3.X',
'user_agent' => 'Symfony',
'tags' => null,
], $auditData, true);
}
Expand Down Expand Up @@ -625,7 +626,7 @@ public function itTransformsTheAuditData()

public function transformAudit(array $data): array
{
$data['new_values']['slug'] = str_slug($data['new_values']['title']);
$data['new_values']['slug'] = Str::slug($data['new_values']['title']);

return $data;
}
Expand Down

0 comments on commit 3d16642

Please sign in to comment.