File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ trait Auditable
63
63
*/
64
64
public static function bootAuditable ()
65
65
{
66
- if (! self :: $ auditingDisabled && static ::isAuditingEnabled ()) {
66
+ if (static ::isAuditingEnabled ()) {
67
67
static ::observe (new AuditableObserver ());
68
68
}
69
69
}
Original file line number Diff line number Diff line change @@ -407,6 +407,31 @@ public function itDisablesAndEnablesAuditingBackAgain()
407
407
$ this ->assertSame (3 , Article::count ());
408
408
}
409
409
410
+ /**
411
+ * @test
412
+ */
413
+ public function itDisablesAndEnablesAuditingBackAgainViaFacade ()
414
+ {
415
+ // Auditing is enabled by default
416
+ $ this ->assertFalse (Article::$ auditingDisabled );
417
+
418
+ Article::disableAuditing ();
419
+
420
+ factory (Article::class)->create ();
421
+
422
+ $ this ->assertSame (1 , Article::count ());
423
+ $ this ->assertSame (0 , Audit::count ());
424
+
425
+ // Enable Auditing
426
+ Article::enableAuditing ();
427
+ $ this ->assertFalse (Article::$ auditingDisabled );
428
+
429
+ factory (Article::class)->create ();
430
+
431
+ $ this ->assertSame (2 , Article::count ());
432
+ $ this ->assertSame (1 , Audit::count ());
433
+ }
434
+
410
435
/**
411
436
* @test
412
437
* @return void
Original file line number Diff line number Diff line change @@ -75,15 +75,16 @@ public function itWillAlwaysAuditModelsWhenNotRunningFromTheConsole()
75
75
* @group Auditable::bootAuditable
76
76
* @test
77
77
*/
78
- public function itWillNotBootTraitWhenStaticFlagIsSet ()
78
+ public function itWillBootTraitWhenStaticFlagIsSet ()
79
79
{
80
80
App::spy ();
81
81
82
82
Article::$ auditingDisabled = true ;
83
83
84
- new Article ();
84
+ $ article = new Article ();
85
85
86
- App::shouldNotHaveReceived ('runningInConsole ' );
86
+ $ this ->assertFalse ($ article ->readyForAuditing ());
87
+ App::shouldReceive ('runningInConsole ' );
87
88
88
89
Article::$ auditingDisabled = false ;
89
90
}
You can’t perform that action at this time.
0 commit comments