function ComponentRenderTest::checkArrayObjectTypeCast
Same name in this branch
- 11.x core/modules/sdc/tests/src/Kernel/ComponentRenderTest.php \Drupal\Tests\sdc\Kernel\ComponentRenderTest::checkArrayObjectTypeCast()
Same name in other branches
- 10 core/modules/sdc/tests/src/Kernel/ComponentRenderTest.php \Drupal\Tests\sdc\Kernel\ComponentRenderTest::checkArrayObjectTypeCast()
- 10 core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php \Drupal\KernelTests\Components\ComponentRenderTest::checkArrayObjectTypeCast()
Ensure fuzzy coercing of arrays and objects works properly.
1 call to ComponentRenderTest::checkArrayObjectTypeCast()
- ComponentRenderTest::testRender in core/
tests/ Drupal/ KernelTests/ Components/ ComponentRenderTest.php - Test that components render correctly.
File
-
core/
tests/ Drupal/ KernelTests/ Components/ ComponentRenderTest.php, line 180
Class
- ComponentRenderTest
- Tests the correct rendering of components.
Namespace
Drupal\KernelTests\ComponentsCode
protected function checkArrayObjectTypeCast() : void {
$content = [
'test' => [],
];
$build = [
'#type' => 'inline_template',
'#context' => [
'content' => $content,
],
'#template' => "{{ include('sdc_test:array-to-object', { testProp: content.test }, with_context = false) }}",
];
try {
$this->renderComponentRenderArray($build);
$this->addToAssertionCount(1);
} catch (\Throwable) {
$this->fail('Empty array was not converted to object');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.