@@ -403,6 +403,7 @@ public function itReturnsTheAuditData()
403
403
404
404
$ this ->assertCount (11 , $ auditData = $ model ->toAudit ());
405
405
406
+ $ morphPrefix = config ('audit.user.morph_prefix ' , 'user ' );
406
407
self ::Assert ()::assertArraySubset ([
407
408
'old_values ' => [],
408
409
'new_values ' => [
@@ -411,15 +412,15 @@ public function itReturnsTheAuditData()
411
412
'reviewed ' => 1 ,
412
413
'published_at ' => $ now ->toDateTimeString (),
413
414
],
414
- 'event ' => 'created ' ,
415
- 'auditable_id ' => null ,
416
- 'auditable_type ' => Article::class,
417
- ' user_id ' => null ,
418
- ' user_type ' => null ,
419
- 'url ' => 'console ' ,
420
- 'ip_address ' => '127.0.0.1 ' ,
421
- 'user_agent ' => 'Symfony ' ,
422
- 'tags ' => null ,
415
+ 'event ' => 'created ' ,
416
+ 'auditable_id ' => null ,
417
+ 'auditable_type ' => Article::class,
418
+ $ morphPrefix . ' _id ' => null ,
419
+ $ morphPrefix . ' _type ' => null ,
420
+ 'url ' => 'console ' ,
421
+ 'ip_address ' => '127.0.0.1 ' ,
422
+ 'user_agent ' => 'Symfony ' ,
423
+ 'tags ' => null ,
423
424
], $ auditData , true );
424
425
}
425
426
@@ -462,6 +463,7 @@ public function itReturnsTheAuditDataIncludingUserAttributes(
462
463
463
464
$ this ->assertCount (11 , $ auditData = $ model ->toAudit ());
464
465
466
+ $ morphPrefix = config ('audit.user.morph_prefix ' , 'user ' );
465
467
self ::Assert ()::assertArraySubset ([
466
468
'old_values ' => [],
467
469
'new_values ' => [
@@ -470,15 +472,15 @@ public function itReturnsTheAuditDataIncludingUserAttributes(
470
472
'reviewed ' => 1 ,
471
473
'published_at ' => $ now ->toDateTimeString (),
472
474
],
473
- 'event ' => 'created ' ,
474
- 'auditable_id ' => null ,
475
- 'auditable_type ' => Article::class,
476
- ' user_id ' => $ id ,
477
- ' user_type ' => $ type ,
478
- 'url ' => 'console ' ,
479
- 'ip_address ' => '127.0.0.1 ' ,
480
- 'user_agent ' => 'Symfony ' ,
481
- 'tags ' => null ,
475
+ 'event ' => 'created ' ,
476
+ 'auditable_id ' => null ,
477
+ 'auditable_type ' => Article::class,
478
+ $ morphPrefix . ' _id ' => $ id ,
479
+ $ morphPrefix . ' _type ' => $ type ,
480
+ 'url ' => 'console ' ,
481
+ 'ip_address ' => '127.0.0.1 ' ,
482
+ 'user_agent ' => 'Symfony ' ,
483
+ 'tags ' => null ,
482
484
], $ auditData , true );
483
485
}
484
486
@@ -544,21 +546,22 @@ public function itExcludesAttributesFromTheAuditDataWhenInStrictMode()
544
546
545
547
$ this ->assertCount (11 , $ auditData = $ model ->toAudit ());
546
548
549
+ $ morphPrefix = config ('audit.user.morph_prefix ' , 'user ' );
547
550
self ::Assert ()::assertArraySubset ([
548
551
'old_values ' => [],
549
552
'new_values ' => [
550
553
'title ' => 'How To Audit Eloquent Models ' ,
551
554
'content ' => 'First step: install the laravel-auditing package. ' ,
552
555
],
553
- 'event ' => 'created ' ,
554
- 'auditable_id ' => null ,
555
- 'auditable_type ' => Article::class,
556
- ' user_id ' => null ,
557
- ' user_type ' => null ,
558
- 'url ' => 'console ' ,
559
- 'ip_address ' => '127.0.0.1 ' ,
560
- 'user_agent ' => 'Symfony ' ,
561
- 'tags ' => null ,
556
+ 'event ' => 'created ' ,
557
+ 'auditable_id ' => null ,
558
+ 'auditable_type ' => Article::class,
559
+ $ morphPrefix . ' _id ' => null ,
560
+ $ morphPrefix . ' _type ' => null ,
561
+ 'url ' => 'console ' ,
562
+ 'ip_address ' => '127.0.0.1 ' ,
563
+ 'user_agent ' => 'Symfony ' ,
564
+ 'tags ' => null ,
562
565
], $ auditData , true );
563
566
}
564
567
0 commit comments