@@ -946,6 +946,41 @@ public function test_can_audit_any_custom_event(): void
946946 ]);
947947 }
948948
949+ public function test_custom_event_does_not_audit_when_auditing_is_disabled (): void
950+ {
951+ config (['audit.enabled ' => false ]);
952+
953+ $ article = Article::factory ()->create ();
954+ $ article ->auditEvent = 'whateverYouWant ' ;
955+ $ article ->isCustomEvent = true ;
956+ $ article ->auditCustomOld = ['customExample ' => 'Anakin Skywalker ' ];
957+ $ article ->auditCustomNew = ['customExample ' => 'Darth Vader ' ];
958+
959+ $ auditCountBefore = Audit::where ('auditable_type ' , Article::class)->count ();
960+
961+ Event::dispatch (new AuditCustom ($ article ));
962+
963+ $ this ->assertSame ($ auditCountBefore , Audit::where ('auditable_type ' , Article::class)->count ());
964+ }
965+
966+ public function test_custom_event_does_not_audit_when_running_in_console_without_console_flag (): void
967+ {
968+ App::shouldReceive ('runningInConsole ' )->andReturn (true );
969+ config (['audit.enabled ' => true , 'audit.console ' => false ]);
970+
971+ $ article = Article::factory ()->create ();
972+ $ article ->auditEvent = 'whateverYouWant ' ;
973+ $ article ->isCustomEvent = true ;
974+ $ article ->auditCustomOld = ['customExample ' => 'Anakin Skywalker ' ];
975+ $ article ->auditCustomNew = ['customExample ' => 'Darth Vader ' ];
976+
977+ $ auditCountBefore = Audit::where ('auditable_type ' , Article::class)->count ();
978+
979+ Event::dispatch (new AuditCustom ($ article ));
980+
981+ $ this ->assertSame ($ auditCountBefore , Audit::where ('auditable_type ' , Article::class)->count ());
982+ }
983+
949984 public function test_can_audit_custom_audit_model_implementation (): void
950985 {
951986 $ audit = null ;
0 commit comments