function ConfigTargetTest::testSetValueMultiTargetToConfigReturnValue
Same name and namespace in other branches
- 10 core/tests/Drupal/Tests/Core/Form/ConfigTargetTest.php \Drupal\Tests\Core\Form\ConfigTargetTest::testSetValueMultiTargetToConfigReturnValue()
- main core/tests/Drupal/Tests/Core/Form/ConfigTargetTest.php \Drupal\Tests\Core\Form\ConfigTargetTest::testSetValueMultiTargetToConfigReturnValue()
Tests set value multi target to config return value.
Attributes
#[TestWith([
"this string was returned by toConfig",
"The toConfig callable returned a string, but it must be an array with a key-value pair for each of the targeted property paths.",
])]
#[TestWith([
TRUE,
"The toConfig callable returned a boolean, but it must be an array with a key-value pair for each of the targeted property paths.",
])]
#[TestWith([
42,
"The toConfig callable returned a integer, but it must be an array with a key-value pair for each of the targeted property paths.",
])]
#[TestWith([
[],
"The toConfig callable returned an array that is missing key-value pairs for the following targeted property paths: first, second.",
])]
#[TestWith([
[
"yar" => 42,
],
"The toConfig callable returned an array that is missing key-value pairs for the following targeted property paths: first, second.",
])]
#[TestWith([
[
"FIRST" => 42,
"SECOND" => 1337,
],
"The toConfig callable returned an array that is missing key-value pairs for the following targeted property paths: first, second.",
])]
#[TestWith([
[
"second" => 42,
],
"The toConfig callable returned an array that is missing key-value pairs for the following targeted property paths: first.",
])]
#[TestWith([
[
"first" => 42,
],
"The toConfig callable returned an array that is missing key-value pairs for the following targeted property paths: second.",
])]
#[TestWith([
[
"first" => 42,
"second" => 1337,
"yar" => "har",
],
"The toConfig callable returned an array that contains key-value pairs that do not match targeted property paths: yar.",
])]
File
-
core/
tests/ Drupal/ Tests/ Core/ Form/ ConfigTargetTest.php, line 365
Class
Namespace
Drupal\Tests\Core\FormCode
public function testSetValueMultiTargetToConfigReturnValue(mixed $toConfigReturnValue, string $expected_exception_message) : void {
$config_target = new ConfigTarget('foo.settings', [
'first',
'second',
], fromConfig: fn(int $first, int $second): string => "{$first}|{$second}", toConfig: fn(): mixed => $toConfigReturnValue);
$config = $this->prophesize(Config::class);
$config->getName()
->willReturn('foo.settings');
$this->expectException(\LogicException::class);
$this->expectExceptionMessageIs($expected_exception_message);
$config_target->setValue($config->reveal(), '1988|1992', $this->prophesize(FormStateInterface::class)
->reveal());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.