Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed Aug 29, 2023
1 parent 5851ed3 commit fe02068
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected function getFormattedValue(Model $model, string $key, $value)
return $model->mutateAttribute($key, $value);
}

if ($model->hasAttributeMutator($key)) {
if (method_exists($model, 'hasAttributeMutator') && $model->hasAttributeMutator($key)) {
return $model->mutateAttributeMarkedAttribute($key, $value);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/AuditingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function itWillAuditTheUpdatedEvent()
], $audit->old_values, true);

self::Assert()::assertArraySubset([
'content' => 'First step: install the laravel-auditing package.',
'content' => 'First Step: Install The Laravel-auditing Package.',
'published_at' => $now->toDateTimeString(),
'reviewed' => 1,
], $audit->new_values, true);
Expand Down
4 changes: 2 additions & 2 deletions tests/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public function getTitleAttribute(string $value): string
public function content(): Attribute
{
return new Attribute(
get: fn ($value) => $value,
set: fn ($value) => ucwords($value),
function ($value) { return $value; },
function ($value) { return ucwords($value); }
);
}
}
14 changes: 7 additions & 7 deletions tests/Unit/AuditableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public function itReturnsTheAuditData()
'old_values' => [],
'new_values' => [
'title' => 'How To Audit Eloquent Models',
'content' => 'First step: install the laravel-auditing package.',
'content' => 'First Step: Install The Laravel-auditing Package.',
'reviewed' => 1,
'published_at' => $now->toDateTimeString(),
],
Expand Down Expand Up @@ -469,7 +469,7 @@ public function itReturnsTheAuditDataIncludingUserAttributes(
'old_values' => [],
'new_values' => [
'title' => 'How To Audit Eloquent Models',
'content' => 'First step: install the laravel-auditing package.',
'content' => 'First Step: Install The Laravel-auditing Package.',
'reviewed' => 1,
'published_at' => $now->toDateTimeString(),
],
Expand Down Expand Up @@ -552,7 +552,7 @@ public function itExcludesAttributesFromTheAuditDataWhenInStrictMode()
'old_values' => [],
'new_values' => [
'title' => 'How To Audit Eloquent Models',
'content' => 'First step: install the laravel-auditing package.',
'content' => 'First Step: Install The Laravel-auditing Package.',
],
'event' => 'created',
'auditable_id' => null,
Expand Down Expand Up @@ -1246,7 +1246,7 @@ public function auditableTransitionTestProvider(): array
// Expectation when transitioning with new values
[
'title' => 'NULLAM EGESTAS INTERDUM ELEIFEND.',
'content' => 'Morbi consectetur laoreet sem, eu tempus odio tempor id.',
'content' => 'Morbi Consectetur Laoreet Sem, Eu Tempus Odio Tempor Id.',
],
],

Expand All @@ -1272,13 +1272,13 @@ public function auditableTransitionTestProvider(): array
// Expectation when transitioning with old values
[
'title' => 'VIVAMUS A URNA ET LOREM FAUCIBUS MALESUADA NEC NEC MAGNA.',
'content' => 'Mauris ipsum erat, semper non quam vel, sodales tincidunt ligula.',
'content' => 'Mauris Ipsum Erat, Semper Non Quam Vel, Sodales Tincidunt Ligula.',
],

// Expectation when transitioning with new values
[
'title' => 'NULLAM EGESTAS INTERDUM ELEIFEND.',
'content' => 'Morbi consectetur laoreet sem, eu tempus odio tempor id.',
'content' => 'Morbi Consectetur Laoreet Sem, Eu Tempus Odio Tempor Id.',
],
],

Expand All @@ -1301,7 +1301,7 @@ public function auditableTransitionTestProvider(): array
// Expectation when transitioning with old values
[
'title' => 'VIVAMUS A URNA ET LOREM FAUCIBUS MALESUADA NEC NEC MAGNA.',
'content' => 'Mauris ipsum erat, semper non quam vel, sodales tincidunt ligula.',
'content' => 'Mauris Ipsum Erat, Semper Non Quam Vel, Sodales Tincidunt Ligula.',
],

// Expectation when transitioning with new values
Expand Down

0 comments on commit fe02068

Please sign in to comment.