Loading core/modules/sdc/src/Component/ComponentValidator.php +4 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,10 @@ public function validateDefinition(array $definition, bool $enforce_schemas): bo } return TRUE; } // If there are no props, force casting to object instead of array. if (($schema['properties'] ?? NULL) === []) { $schema['properties'] = new \stdClass(); } $classes_per_prop = $this->getClassProps($schema); $missing_class_errors = []; foreach ($classes_per_prop as $prop_name => $class_types) { Loading core/modules/sdc/tests/modules/sdc_test/components/no-props/no-props.component.yml 0 → 100644 +6 −0 Original line number Diff line number Diff line $schema: https://git.drupalcode.org/project/sdc/-/raw/1.x/src/metadata.schema.json name: No props description: Component without properties props: type: object properties: {} core/modules/sdc/tests/modules/sdc_test/components/no-props/no-props.twig 0 → 100644 +1 −0 Original line number Diff line number Diff line This is a test string. core/modules/sdc/tests/src/Kernel/ComponentRenderTest.php +17 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ public function testRender(): void { $this->checkRenderElementAlters(); $this->checkSlots(); $this->checkInvalidSlot(); $this->checkEmptyProps(); } /** Loading Loading @@ -335,6 +336,22 @@ public function checkInvalidSlot(): void { $this->renderComponentRenderArray($build); } /** * Ensure that components can have 0 props. */ public function checkEmptyProps(): void { $build = [ '#type' => 'component', '#component' => 'sdc_test:no-props', '#props' => [], ]; $crawler = $this->renderComponentRenderArray($build); $this->assertEquals( $crawler->filter('#sdc-wrapper')->innerText(), 'This is a test string.' ); } /** * Ensures some key aspects of the plugin definition are correctly computed. * Loading Loading
core/modules/sdc/src/Component/ComponentValidator.php +4 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,10 @@ public function validateDefinition(array $definition, bool $enforce_schemas): bo } return TRUE; } // If there are no props, force casting to object instead of array. if (($schema['properties'] ?? NULL) === []) { $schema['properties'] = new \stdClass(); } $classes_per_prop = $this->getClassProps($schema); $missing_class_errors = []; foreach ($classes_per_prop as $prop_name => $class_types) { Loading
core/modules/sdc/tests/modules/sdc_test/components/no-props/no-props.component.yml 0 → 100644 +6 −0 Original line number Diff line number Diff line $schema: https://git.drupalcode.org/project/sdc/-/raw/1.x/src/metadata.schema.json name: No props description: Component without properties props: type: object properties: {}
core/modules/sdc/tests/modules/sdc_test/components/no-props/no-props.twig 0 → 100644 +1 −0 Original line number Diff line number Diff line This is a test string.
core/modules/sdc/tests/src/Kernel/ComponentRenderTest.php +17 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ public function testRender(): void { $this->checkRenderElementAlters(); $this->checkSlots(); $this->checkInvalidSlot(); $this->checkEmptyProps(); } /** Loading Loading @@ -335,6 +336,22 @@ public function checkInvalidSlot(): void { $this->renderComponentRenderArray($build); } /** * Ensure that components can have 0 props. */ public function checkEmptyProps(): void { $build = [ '#type' => 'component', '#component' => 'sdc_test:no-props', '#props' => [], ]; $crawler = $this->renderComponentRenderArray($build); $this->assertEquals( $crawler->filter('#sdc-wrapper')->innerText(), 'This is a test string.' ); } /** * Ensures some key aspects of the plugin definition are correctly computed. * Loading