Update TestsForms.php

This commit is contained in:
Dan Harrin
2025-04-20 21:16:41 +01:00
parent c45ce48559
commit 1ba677a9c4
+12 -2
View File
@@ -83,8 +83,18 @@ class TestsForms
}
if (is_array($state)) {
foreach (Arr::dot($state, prepend: filled($formSchemaStatePath) ? "{$formSchemaStatePath}." : '') as $key => $value) {
$this->assertSet($key, $value);
$components = $formSchema->getFlatComponents(withActions: false, withHidden: true);
foreach ($state as $key => $value) {
if (array_key_exists($key, $components)) {
Assert::assertEquals(
$value,
$components[$key]->getState(),
message: "Failed asserting that the form [{$schema}] has a component [{$key}] set to the expected value.",
);
} else {
$this->assertSet((filled($formSchemaStatePath) ? "{$formSchemaStatePath}." : '') . $key, $value);
}
}
}