Skip to content

Commit

Permalink
Merge pull request #581 from RossAHC/laravel-7
Browse files Browse the repository at this point in the history
Upgrade to Laravel 7
  • Loading branch information
anteriovieira authored Mar 23, 2020
2 parents 5574786 + 7068e2c commit 50b0d9b
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build:
php72:
environment:
php:
version: 7.2.0
version: 7.2.5
tests:
override:
- php-scrutinizer-run
Expand Down
1 change: 0 additions & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ risky: true

enabled:
- php_unit_strict
- return_type_declaration

disabled:
- self_accessor
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ The package documentation can be found on the [official website](http://www.lara
## Version Information
Version | Illuminate | Status | PHP Version
:----------|:--------------|:------------------------|:------------
9.x | 5.8.x - 6.x.x | Active support :rocket: | >= 7.1.3
10.x | 5.8.x - 7.x.x | Active support :rocket: | >= 7.2.5
9.x | 5.8.x - 6.x.x | Active support | >= 7.1.3
8.x | 5.2.x - 5.7.x | Active support | >= 7.0.13
7.x | 5.2.x - 5.6.x | End of life | >= 7.0.13
6.x | 5.2.x - 5.6.x | End of life | >= 7.0.13
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
}
],
"require": {
"php": ">=7.2",
"illuminate/console": "^5.8|^6.0",
"illuminate/database": "^5.8|^6.0",
"illuminate/filesystem": "^5.8|^6.0"
"php": ">=7.2.5",
"illuminate/console": "^5.8|^6.0|^7.0",
"illuminate/database": "^5.8|^6.0|^7.0",
"illuminate/filesystem": "^5.8|^6.0|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
Expand All @@ -65,7 +65,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "9.0-dev"
"dev-master": "10.0-dev"
},
"laravel": {
"providers": [
Expand Down
6 changes: 2 additions & 4 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
namespace OwenIt\Auditing\Console;

use Illuminate\Console\Command;
use Illuminate\Console\DetectsApplicationNamespace;
use Illuminate\Container\Container;
use Illuminate\Support\Str;

class InstallCommand extends Command
{
use DetectsApplicationNamespace;

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -43,7 +41,7 @@ public function handle()
*/
protected function registerAuditingServiceProvider()
{
$namespace = Str::replaceLast('\\', '', $this->getAppNamespace());
$namespace = Str::replaceLast('\\', '', Container::getInstance()->getNamespace());

$appConfig = file_get_contents(config_path('app.php'));

Expand Down
13 changes: 7 additions & 6 deletions tests/Functional/AuditingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace OwenIt\Auditing\Tests\Functional;

use Carbon\Carbon;
use Illuminate\Foundation\Testing\Assert;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Event;
use InvalidArgumentException;
Expand Down Expand Up @@ -142,7 +143,7 @@ public function itWillAuditTheCreatedEvent()

$this->assertEmpty($audit->old_values);

$this->assertArraySubset([
Assert::assertArraySubset([
'title' => 'How To Audit Eloquent Models',
'content' => 'N/A',
'published_at' => null,
Expand Down Expand Up @@ -177,13 +178,13 @@ public function itWillAuditTheUpdatedEvent()

$audit = Audit::first();

$this->assertArraySubset([
Assert::assertArraySubset([
'content' => 'N/A',
'published_at' => null,
'reviewed' => 0,
], $audit->old_values, true);

$this->assertArraySubset([
Assert::assertArraySubset([
'content' => 'First step: install the laravel-auditing package.',
'published_at' => $now->toDateTimeString(),
'reviewed' => 1,
Expand All @@ -210,7 +211,7 @@ public function itWillAuditTheDeletedEvent()

$audit = Audit::first();

$this->assertArraySubset([
Assert::assertArraySubset([
'title' => 'How To Audit Eloquent Models',
'content' => 'N/A',
'published_at' => null,
Expand Down Expand Up @@ -244,7 +245,7 @@ public function itWillAuditTheRestoredEvent()

$this->assertEmpty($audit->old_values);

$this->assertArraySubset([
Assert::assertArraySubset([
'title' => 'How To Audit Eloquent Models',
'content' => 'N/A',
'published_at' => null,
Expand Down Expand Up @@ -344,7 +345,7 @@ public function itWillAuditUsingTheDefaultDriver()

$this->assertEmpty($audit->old_values);

$this->assertArraySubset([
Assert::assertArraySubset([
'title' => 'How To Audit Using The Fallback Driver',
'content' => 'N/A',
'published_at' => null,
Expand Down
19 changes: 10 additions & 9 deletions tests/Unit/AuditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Carbon\Carbon;
use DateTimeInterface;
use Illuminate\Foundation\Testing\Assert;
use OwenIt\Auditing\Encoders\Base64Encoder;
use OwenIt\Auditing\Models\Audit;
use OwenIt\Auditing\Redactors\LeftRedactor;
Expand Down Expand Up @@ -31,7 +32,7 @@ public function itResolvesAuditData()

$this->assertCount(15, $resolvedData = $audit->resolveData());

$this->assertArraySubset([
Assert::assertArraySubset([
'audit_id' => 1,
'audit_event' => 'created',
'audit_url' => 'console',
Expand Down Expand Up @@ -78,7 +79,7 @@ public function itResolvesAuditDataIncludingUserAttributes()

$this->assertCount(21, $resolvedData = $audit->resolveData());

$this->assertArraySubset([
Assert::assertArraySubset([
'audit_id' => 2,
'audit_event' => 'created',
'audit_url' => 'console',
Expand Down Expand Up @@ -159,7 +160,7 @@ public function itReturnsAuditMetadataAsArray()

$this->assertCount(10, $metadata = $audit->getMetadata());

$this->assertArraySubset([
Assert::assertArraySubset([
'audit_id' => 1,
'audit_event' => 'created',
'audit_url' => 'console',
Expand Down Expand Up @@ -192,7 +193,7 @@ public function itReturnsAuditMetadataIncludingUserAttributesAsArray()

$this->assertCount(16, $metadata = $audit->getMetadata());

$this->assertArraySubset([
Assert::assertArraySubset([
'audit_id' => 2,
'audit_event' => 'created',
'audit_url' => 'console',
Expand Down Expand Up @@ -300,7 +301,7 @@ public function itReturnsAuditableModifiedAttributesAsArray()

$this->assertCount(5, $modified = $audit->getModified());

$this->assertArraySubset([
Assert::assertArraySubset([
'title' => [
'new' => 'HOW TO AUDIT ELOQUENT MODELS',
],
Expand Down Expand Up @@ -391,7 +392,7 @@ public function itReturnsDecodedAuditableAttributes()

$this->assertCount(3, $modified = $audit->getModified());

$this->assertArraySubset([
Assert::assertArraySubset([
'title' => [
'new' => 'HOW TO AUDIT ELOQUENT MODELS',
'old' => 'HOW TO AUDIT MODELS',
Expand All @@ -417,8 +418,8 @@ public function itReturnsTags()
'tags' => 'foo,bar,baz',
]);

$this->assertInternalType('array', $audit->getTags());
$this->assertArraySubset([
$this->assertIsArray($audit->getTags());
Assert::assertArraySubset([
'foo',
'bar',
'baz',
Expand All @@ -435,7 +436,7 @@ public function itReturnsEmptyTags()
'tags' => null,
]);

$this->assertInternalType('array', $audit->getTags());
$this->assertIsArray($audit->getTags());
$this->assertEmpty($audit->getTags());
}
}
31 changes: 16 additions & 15 deletions tests/Unit/AuditableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Foundation\Testing\Assert;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Str;
use OwenIt\Auditing\Contracts\Auditable;
Expand Down Expand Up @@ -115,7 +116,7 @@ public function itReturnsTheDefaultAuditEvents()
{
$model = new Article();

$this->assertArraySubset([
Assert::assertArraySubset([
'created',
'updated',
'deleted',
Expand All @@ -136,7 +137,7 @@ public function itReturnsTheCustomAuditEventsFromAttribute()
'archived',
];

$this->assertArraySubset([
Assert::assertArraySubset([
'published' => 'getPublishedEventAttributes',
'archived',
], $model->getAuditEvents(), true);
Expand All @@ -155,7 +156,7 @@ public function itReturnsTheCustomAuditEventsFromConfig()

$model = new Article();

$this->assertArraySubset([
Assert::assertArraySubset([
'published' => 'getPublishedEventAttributes',
'archived',
], $model->getAuditEvents(), true);
Expand Down Expand Up @@ -399,7 +400,7 @@ public function itReturnsTheAuditData()

$this->assertCount(11, $auditData = $model->toAudit());

$this->assertArraySubset([
Assert::assertArraySubset([
'old_values' => [],
'new_values' => [
'title' => 'How To Audit Eloquent Models',
Expand Down Expand Up @@ -458,7 +459,7 @@ public function itReturnsTheAuditDataIncludingUserAttributes(

$this->assertCount(11, $auditData = $model->toAudit());

$this->assertArraySubset([
Assert::assertArraySubset([
'old_values' => [],
'new_values' => [
'title' => 'How To Audit Eloquent Models',
Expand Down Expand Up @@ -540,7 +541,7 @@ public function itExcludesAttributesFromTheAuditDataWhenInStrictMode()

$this->assertCount(11, $auditData = $model->toAudit());

$this->assertArraySubset([
Assert::assertArraySubset([
'old_values' => [],
'new_values' => [
'title' => 'How To Audit Eloquent Models',
Expand Down Expand Up @@ -610,7 +611,7 @@ public function itModifiesTheAuditAttributesSuccessfully()
'reviewed' => Base64Encoder::class,
];

$this->assertArraySubset([
Assert::assertArraySubset([
'old_values' => [
'title' => 'Ho#################',
'content' => '##A',
Expand Down Expand Up @@ -654,7 +655,7 @@ public function transformAudit(array $data): array

$this->assertCount(11, $auditData = $model->toAudit());

$this->assertArraySubset([
Assert::assertArraySubset([
'new_values' => [
'title' => 'How To Audit Eloquent Models',
'content' => 'First step: install the laravel-auditing package.',
Expand All @@ -673,7 +674,7 @@ public function itReturnsTheDefaultAttributesToBeIncludedInTheAudit()
{
$model = new Article();

$this->assertArraySubset([], $model->getAuditInclude(), true);
Assert::assertArraySubset([], $model->getAuditInclude(), true);
}

/**
Expand All @@ -689,7 +690,7 @@ public function itReturnsTheCustomAttributesToBeIncludedInTheAudit()
'content',
];

$this->assertArraySubset([
Assert::assertArraySubset([
'title',
'content',
], $model->getAuditInclude(), true);
Expand All @@ -703,7 +704,7 @@ public function itReturnsTheDefaultAttributesToBeExcludedFromTheAudit()
{
$model = new Article();

$this->assertArraySubset([], $model->getAuditExclude(), true);
Assert::assertArraySubset([], $model->getAuditExclude(), true);
}

/**
Expand All @@ -718,7 +719,7 @@ public function itReturnsTheCustomAttributesToBeExcludedFromTheAudit()
'published_at',
];

$this->assertArraySubset([
Assert::assertArraySubset([
'published_at',
], $model->getAuditExclude(), true);
}
Expand Down Expand Up @@ -879,7 +880,7 @@ public function itReturnsTheDefaultGeneratedAuditTags()
{
$model = new Article();

$this->assertArraySubset([], $model->generateTags(), true);
Assert::assertArraySubset([], $model->generateTags(), true);
}

/**
Expand All @@ -898,7 +899,7 @@ public function generateTags(): array
}
};

$this->assertArraySubset([
Assert::assertArraySubset([
'foo',
'bar',
], $model->generateTags(), true);
Expand Down Expand Up @@ -1061,7 +1062,7 @@ public function itFailsToTransitionWhenTheAuditableAttributeCompatibilityIsNotMe
$e->getMessage()
);

$this->assertArraySubset([
Assert::assertArraySubset([
'subject',
'text',
], $e->getIncompatibilities(), true);
Expand Down

0 comments on commit 50b0d9b

Please sign in to comment.