Skip to content

Commit fb66b87

Browse files
committed
improve test ii
1 parent 994a297 commit fb66b87

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

tests/FormTest.php

+19-11
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,26 @@ public function testSubmitNonFormFieldError(): void
183183
$m = $m->createEntity();
184184
$this->form->setModel($m, ['foo']);
185185

186+
$submitReached = false;
187+
$catchReached = false;
186188
try {
187-
$this->assertSubmit(['foo' => 'x'], function (Model $model) {
188-
$model->set('bar', null);
189-
});
190-
191-
static::assertFalse(true);
192-
} catch (UnhandledCallbackExceptionError $e) {
193-
$this->expectException(ValidationException::class);
194-
$this->expectExceptionMessage('Must not be null');
195-
static::assertSame('bar', $e->getPrevious()->getParams()['field']->shortName);
196-
197-
throw $e->getPrevious();
189+
try {
190+
$this->assertSubmit(['foo' => 'x'], function (Model $model) use (&$submitReached) {
191+
$submitReached = true;
192+
$model->set('bar', null);
193+
});
194+
} catch (UnhandledCallbackExceptionError $e) {
195+
$catchReached = true;
196+
static::assertSame('bar', $e->getPrevious()->getParams()['field']->shortName); // @phpstan-ignore-line
197+
198+
$this->expectException(ValidationException::class);
199+
$this->expectExceptionMessage('Must not be null');
200+
201+
throw $e->getPrevious();
202+
}
203+
} finally {
204+
static::assertTrue($submitReached);
205+
static::assertTrue($catchReached);
198206
}
199207
}
200208
}

0 commit comments

Comments
 (0)