File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -70,17 +70,22 @@ public function seeAudit(array $values)
7070 // Check each audit in the queue for a match
7171 foreach ($ queue as $ audit )
7272 {
73+ $ found = true ;
74+
7375 // Check each value against the audit
7476 foreach ($ values as $ key => $ value )
7577 {
7678 if ($ audit [$ key ] != $ value )
7779 {
78- break 2 ;
80+ $ found = false ;
81+ break ;
7982 }
8083 }
8184
82- $ found = true ;
83- break ;
85+ if ($ found )
86+ {
87+ break ;
88+ }
8489 }
8590
8691 $ this ->assertTrue ($ found , 'Audit not found in queue: ' . print_r ($ values , true ));
Original file line number Diff line number Diff line change 11<?php
22
33use Tests \Support \DatabaseTestCase ;
4+ use Tests \Support \Models \WidgetModel ;
45
56class TraitTest extends DatabaseTestCase
67{
@@ -16,12 +17,35 @@ public function testInsertAddsAudit()
1617 'source_id ' => $ result ,
1718 'event ' => 'insert ' ,
1819 'summary ' => '5 fields ' ,
19- 'user_id ' => - 1 ,
20+ 'user_id ' => 0 ,
2021 ];
2122
2223 $ queue = service ('audits ' )->getQueue ();
2324
2425 $ this ->assertCount (1 , $ queue );
2526 $ this ->seeAudit ($ expected );
2627 }
28+
29+ public function testUpdateAddsAudit ()
30+ {
31+ $ widget = fake (WidgetModel::class);
32+ $ widgetId = $ widget ->id ; // @phpstan-ignore-line
33+
34+ $ this ->model ->update ($ widgetId , [
35+ 'name ' => 'Banana Widget ' ,
36+ ]);
37+
38+ $ expected = [
39+ 'source ' => 'widgets ' ,
40+ 'source_id ' => [$ widgetId ],
41+ 'event ' => 'update ' ,
42+ 'summary ' => '2 fields ' ,
43+ 'user_id ' => 0 ,
44+ ];
45+
46+ $ queue = service ('audits ' )->getQueue ();
47+
48+ $ this ->assertCount (2 , $ queue );
49+ $ this ->seeAudit ($ expected );
50+ }
2751}
You can’t perform that action at this time.
0 commit comments