$edit =
[ 'field_single[0][value]' => 1,
'field_unlimited[0][value]' => 2,
'field_unlimited[1][value]' => 3,
'entity_2[field_single][0][value]' => 11,
'entity_2[field_unlimited][0][value]' => 12,
'entity_2[field_unlimited][1][value]' => 13,
];
$this->
submitForm($edit, 'Save'
);
$entity_1 =
$storage->
load(1
);
$entity_2 =
$storage->
load(2
);
$this->
assertFieldValues($entity_1, 'field_single',
[1
]);
$this->
assertFieldValues($entity_1, 'field_unlimited',
[2, 3
]);
$this->
assertFieldValues($entity_2, 'field_single',
[11
]);
$this->
assertFieldValues($entity_2, 'field_unlimited',
[12, 13
]);
// Submit invalid values and check that errors are reported on the
// correct widgets.
$edit =
[ 'field_unlimited[1][value]' => -1,
];
$this->
drupalGet('test-entity/nested/1/2'
);
$this->
submitForm($edit, 'Save'
);