Skip to content

Commit 152d47a

Browse files
committed
Add failing test.
1 parent 0c65a20 commit 152d47a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/Fields/BlueprintTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,41 @@ public function it_ensures_a_field_has_config()
895895

896896
// todo: duplicate or tweak above test but make the target field not in the first section.
897897

898+
#[Test]
899+
public function it_can_ensure_an_deferred_ensured_field_has_specific_config()
900+
{
901+
$blueprint = (new Blueprint)->setContents(['tabs' => [
902+
'tab_one' => [
903+
'sections' => [
904+
[
905+
'fields' => [
906+
['handle' => 'title', 'field' => ['type' => 'text']],
907+
],
908+
],
909+
],
910+
],
911+
]]);
912+
913+
// Let's say somewhere else in the code ensures an `author` field
914+
$blueprint->ensureField('author', ['type' => 'text', 'do_not_touch_other_config' => true, 'foo' => 'bar']);
915+
916+
// Then later, we try to ensure that `author` field has config, we should be able to successfully modify that deferred field
917+
$fields = $blueprint
918+
->ensureFieldHasConfig('author', ['foo' => 'baz', 'visibility' => 'read_only'])
919+
->fields();
920+
921+
$this->assertEquals(['type' => 'text'], $fields->get('title')->config());
922+
923+
$expectedConfig = [
924+
'type' => 'text',
925+
'do_not_touch_other_config' => true,
926+
'foo' => 'baz',
927+
'visibility' => 'read_only',
928+
];
929+
930+
$this->assertEquals($expectedConfig, $fields->get('author')->config());
931+
}
932+
898933
#[Test]
899934
public function it_merges_previously_undefined_keys_into_the_config_when_ensuring_a_field_exists_and_it_already_exists()
900935
{

0 commit comments

Comments
 (0)