File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -46,4 +46,12 @@ public function getErrors(): array
4646
4747 return $ return ;
4848 }
49+
50+ /**
51+ * @return \Cake\Datasource\EntityInterface|null
52+ */
53+ public function getEntity (): ?EntityInterface
54+ {
55+ return $ this ->entity ;
56+ }
4957}
Original file line number Diff line number Diff line change @@ -51,6 +51,20 @@ public function test_validation_exception(): void
5151 ]);
5252 }
5353
54+ public function test_validation_exception_get_entity (): void
55+ {
56+ $ this ->expectException (ValidationException::class);
57+
58+ new EntityValidationListener ();
59+
60+ $ actorsTable = new ActorsTable ();
61+ $ entity = $ actorsTable ->patchEntity ($ actorsTable ->newEmptyEntity (), [
62+ 'first_name ' => '' ,
63+ 'last_name ' => ''
64+ ]);
65+ $ this ->assertInstanceOf (EntityInterface::class, $ entity );
66+ }
67+
5468 public function test_validation_exception_does_not_run_when_cli (): void
5569 {
5670 Configure::write ('MixerApi.ExceptionRender.entity_validation ' , false );
Original file line number Diff line number Diff line change @@ -10,5 +10,6 @@ class ValidationExceptionTest extends TestCase
1010 public function test_get_errors_returns_empty_array_on_null_entity (): void
1111 {
1212 $ this ->assertCount (0 , (new ValidationException ())->getErrors ());
13+ $ this ->assertNull ((new ValidationException ())->getEntity ());
1314 }
1415}
You can’t perform that action at this time.
0 commit comments