Skip to content
Snippets Groups Projects

Draft: #3487284

1 file
+ 10
12
Compare changes
  • Side-by-side
  • Inline
@@ -69,11 +69,7 @@ class PropShapeRepositoryTest extends KernelTestBase {
* Tests finding all unique prop schemas.
*/
public function testUniquePropSchemaDiscovery(): array {
$sdc_manager = \Drupal::service('plugin.manager.sdc');
$matcher = \Drupal::service(SdcPropToFieldTypePropMatcher::class);
assert($matcher instanceof SdcPropToFieldTypePropMatcher);
$components = $sdc_manager->getAllComponents();
$components = \Drupal::service('plugin.manager.sdc')->getAllComponents();
$unique_prop_shapes = [];
foreach ($components as $component) {
foreach (PropShape::getComponentProps($component) as $prop_shape) {
@@ -490,22 +486,24 @@ class PropShapeRepositoryTest extends KernelTestBase {
$this->assertNotEmpty($unique_prop_shapes);
$unique_storable_prop_shapes = [];
$unstorable_prop_shapes = [];
foreach ($unique_prop_shapes as $prop_shape) {
assert($prop_shape instanceof PropShape);
// If this prop shape is not storable, then fall back to the PropShape
// object, to make it easy to assert which shapes are storable vs not.
$unique_storable_prop_shapes[$prop_shape->uniquePropSchemaKey()] = $prop_shape->getStorage() ?? $prop_shape;
$key = $prop_shape->uniquePropSchemaKey();
if ($prop_shape_storage = $prop_shape->getStorage()) {
$unique_storable_prop_shapes[$key] = $prop_shape_storage;
}
else {
$unstorable_prop_shapes[$key] = $prop_shape;
}
}
$unstorable_prop_shapes = array_filter($unique_storable_prop_shapes, fn ($s) => $s instanceof PropShape);
$unique_storable_prop_shapes = array_filter($unique_storable_prop_shapes, fn ($s) => $s instanceof StorablePropShape);
$this->assertEquals(static::getExpectedStorablePropShapes(), $unique_storable_prop_shapes);
// ⚠️ No field type + widget yet for these! For some that is fine though.
$this->assertEquals(static::getExpectedUnstorablePropShapes(), $unstorable_prop_shapes);
return array_filter($unique_storable_prop_shapes, fn ($prop_shape) => $prop_shape instanceof StorablePropShape);
return $unique_storable_prop_shapes;
}
/**
Loading