@@ -31,6 +31,36 @@ public function testModelViolationReportersCanBeRegistered(): void
3131 Model::handleDiscardedAttributeViolationUsing (Integration::discardedAttributeViolationReporter ());
3232 }
3333
34+ public function testViolationReporterAcceptsSingleProperty (): void
35+ {
36+ $ reporter = Integration::discardedAttributeViolationReporter (null , true , false );
37+
38+ $ reporter (new ViolationReporterTestModel , 'foo ' );
39+
40+ $ this ->assertCount (1 , $ this ->getCapturedSentryEvents ());
41+
42+ $ violation = $ this ->getLastSentryEvent ()->getContexts ()['violation ' ];
43+
44+ $ this ->assertSame ('foo ' , $ violation ['attribute ' ]);
45+ $ this ->assertSame ('discarded_attribute ' , $ violation ['kind ' ]);
46+ $ this ->assertSame (ViolationReporterTestModel::class, $ violation ['model ' ]);
47+ }
48+
49+ public function testViolationReporterAcceptsListOfProperties (): void
50+ {
51+ $ reporter = Integration::discardedAttributeViolationReporter (null , true , false );
52+
53+ $ reporter (new ViolationReporterTestModel , ['foo ' , 'bar ' ]);
54+
55+ $ this ->assertCount (1 , $ this ->getCapturedSentryEvents ());
56+
57+ $ violation = $ this ->getLastSentryEvent ()->getContexts ()['violation ' ];
58+
59+ $ this ->assertSame ('foo, bar ' , $ violation ['attribute ' ]);
60+ $ this ->assertSame ('discarded_attribute ' , $ violation ['kind ' ]);
61+ $ this ->assertSame (ViolationReporterTestModel::class, $ violation ['model ' ]);
62+ }
63+
3464 public function testViolationReporterPassesThroughToCallback (): void
3565 {
3666 $ callbackCalled = false ;
0 commit comments