DX: update `PropShapeToFieldInstanceTest` to not test all SDCs, but only those that meet XB's requirements

Created on 31 July 2025, about 2 months ago
📌 Task
Status

Active

Version

1.0

Component

Shape matching

Created by

🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @wim leers
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Starting point:

    diff --git a/tests/src/Kernel/PropShapeToFieldInstanceTest.php b/tests/src/Kernel/PropShapeToFieldInstanceTest.php
    index 8152f3580..8c6e46a4b 100644
    --- a/tests/src/Kernel/PropShapeToFieldInstanceTest.php
    +++ b/tests/src/Kernel/PropShapeToFieldInstanceTest.php
    @@ -169,12 +169,17 @@ class PropShapeToFieldInstanceTest extends KernelTestBase {
         );
         ksort($components);
     
    -    // Removing some test components that have been enabled due to all SDCs now
    -    // in xb_test_sdc module.
    -    $components_to_remove = ['crash', 'component-no-meta-enum', 'component-mismatch-meta-enum', 'empty-enum', 'deprecated', 'experimental', 'image-gallery', 'image-optional-with-example-and-additional-prop', 'obsolete', 'grid-container', 'html-invalid-format', 'my-cta', 'sparkline', 'sparkline_min_2', 'props-invalid-shapes', 'props-no-examples', 'props-no-slots', 'props-no-title', 'props-slots', 'image-optional-with-example', 'image-optional-without-example', 'image-required-with-example', 'image-required-with-invalid-example', 'image-required-without-example'];
    -    foreach ($components_to_remove as $key) {
    -      unset($components['xb_test_sdc:' . $key]);
    -    }
    +    $component_config_entities = \Drupal\experience_builder\Entity\Component::loadMultiple();
    +    $component_id_to_sdc_id = array_combine(
    +      array_map(
    +        fn ($s) => \Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\SingleDirectoryComponent::convertMachineNameToId($s),
    +        array_keys($components)
    +      ),
    +      array_keys($components),
    +    );
    +    $components_to_keep = array_intersect_key($component_config_entities, $component_id_to_sdc_id);
    +    $sdc_ids_to_keep = array_flip(array_values(array_intersect_key($component_id_to_sdc_id, $components_to_keep)));
    +    $components = array_intersect_key($components, $sdc_ids_to_keep);
     
         foreach ($components as $component) {
           // Do not find a match for every unique SDC prop, but only for unique prop
    

    … then update the expectations to make this pass. 🙏

  • Hi Wim 👋

    Thanks for the detailed starting point!

    I’m picking up this ticket and assigning it to myself. I’ll begin working on updating the test logic and adjusting the expectations accordingly.

    Will share updates soon

  • Hello Wim,

    I am un-assigning myself from this issue because I've found a fundamental bug in the test suite that is preventing me from proceeding. The test PropShapeToFieldInstanceTest.php consistently fails with the error Drupal\Component\Plugin\Exception\PluginNotFoundException: The "xb_page" entity type does not exist.

    This is not a simple setup issue. I have performed an exhaustive debugging process, and the error persists even on a completely clean, unmodified codebase.

    Here is a summary of the debugging steps taken:

    • Configured phpunit.xml for SQLite and verified the correct bootstrap path.
    • Found and removed a SIMPLETEST_DB environment variable override from my shell profile.
    • Verified the test's $modules array correctly includes both 'experience_builder' and 'views'.
    • Verified via a recursive grep that the Page.php entity's ID is correctly defined as 'xb_page'.
    • Ran all tests inside the DDEV container using ddev exec.
    • Attempted to clear all possible caches with ddev restart, ddev mutagen reset, ddev composer dump-autoload, and ddev drush cr.
    • Finally, I completely destroyed the DDEV environment with ddev delete, reverted all my code changes with git checkout, and rebuilt the project from scratch with ddev composer install.

    Even after all of this, the unmodified test still fails with the same "xb_page entity type does not exist" error.

    This proves the bug is within the module's test suite. It seems that under some conditions, the test is unable to discover its own module's entity definitions. This underlying issue needs to be fixed by a maintainer before this ticket's original goal can be accomplished.

    Thank you!

Production build 0.71.5 2024