It's all in the title.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Title: Convert all hooks to OOP format » Convert the help hook to OOP format and add tests
mably’s picture

Here is a patch that addresses the OOP hooks conversion, adds comprehensive functional tests, and fixes a bug discovered during testing.

OOP Hooks Conversion

  • Created src/Hook/DomainThemeSwitchHooks.php with #[Hook('help')] attribute and StringTranslationTrait
  • Created domain_theme_switch.services.yml to register the hook class as a service
  • Updated domain_theme_switch.module with #[LegacyHook] delegation for Drupal 10.6 backward compatibility

Bug Fix in DomainThemeSwitchConfigForm::submitForm()

Discovered during testing: when enabling a theme override for the first time, $domain_collection->read('system.theme') returns FALSE (no config exists in the domain collection yet). The code was trying to access ['default'] and ['admin'] on FALSE, causing PHP warnings. Fixed by falling back to the base system.theme config when no domain override exists yet.

Functional Tests — 7 test methods, 87 assertions

Created tests/src/Functional/DomainThemeSwitchFormTest.php extending DomainTestBase with full coverage of the configuration form:

  1. testFormWithNoDomains — Verifies "Zero domain records found" message, "click here" link, and no submit button when no domains exist
  2. testFormDisplaysWithDomains — Verifies fieldsets per domain, override checkboxes (unchecked by default), theme select fields, and submit button
  3. testEnableThemeOverride — Enables override for one domain, verifies form state and config collection written correctly, second domain unaffected
  4. testDisableThemeOverride — Enables then disables override, verifies form state and config collection removed
  5. testUpdateThemeOverride — Enables override, changes theme values, verifies form state and config collection updated
  6. testMultipleDomainOverrides — Enables overrides for 2 of 3 domains simultaneously, verifies each domain's config independently
  7. testSiteThemeOverrideRendered — End-to-end verification that the site theme is actually applied on rendered pages: checks stark assets are present before override, then after switching to olivero via domain config, verifies olivero assets are loaded and stark assets are gone

mably’s picture

Status: Active » Needs review

  • mably committed 50e2140c on 3.x
    task: #3574050 Convert the help hook to OOP format and add tests
    
    By:...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.