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 all hooks to OOP format and add tests
mably’s picture

Status: Active » Needs review
mably’s picture

Convert all hooks to OOP format and add tests

OOP hooks conversion

Converted all hook implementations across the main module and all 11 sub-modules from procedural .module functions to OOP classes using #[Hook] attributes, with #[LegacyHook] delegations in .module files for Drupal 10.6 backward compatibility.

Main module:

  • src/Hook/ViewsFiltersSummaryHooks.phphook_theme(), hook_views_data(), hook_views_filters_summary_filter_value_alter(), hook_views_filters_summary_plugin_alias()

Sub-modules converted (11):

  • views_filters_summary_a11y — accessibility hooks
  • views_filters_summary_address — address field support
  • views_filters_summary_bef — Better Exposed Filters support
  • views_filters_summary_commerce — Commerce integration
  • views_filters_summary_cvfb — custom views filter block support
  • views_filters_summary_eb — ECA/Block support
  • views_filters_summary_eref — entity reference support
  • views_filters_summary_search_api — Search API integration
  • views_filters_summary_vcer — Views Contextual Entity Reference support
  • views_filters_summary_verf — Views Entity Reference Filter support
  • views_filters_summary_vsf — Views Selective Filters support

Each sub-module now has:

  • A src/Hook/ class with #[Hook] attributes
  • A .services.yml registering the hook class
  • A .module file with #[LegacyHook] for Drupal 10.6 compatibility

Kernel tests (13 test methods, 254 assertions)

Added tests/src/Kernel/ViewsFiltersSummaryKernelTest.php covering the area plugin rendering logic:

  1. testNoSummaryWithoutExposedInput — no summary when no filters active
  2. testStringFilter — string filter value appears in summary
  3. testStringFilterOperators — operator labels (!=, contains, starts, ends)
  4. testBundleFilter — human-readable bundle label (not machine name)
  5. testBooleanFilter — boolean shows "Yes"/"No" label
  6. testTaxonomyFilter — taxonomy term labels (not tids)
  7. testShowLabelsOption — filter label display toggle
  8. testRemoveAndResetLinks — remove/reset link rendering
  9. testFilterSelectionOption — limiting summary to specific filters
  10. testPrefixAndSeparator — custom prefix and separator
  11. testResultLabel — singular/plural result labels
  12. testEmptyResults — empty results behavior with empty option
  13. testGroupedFilter — grouped filter displays group item title

Also added the test infrastructure: views_filters_summary_test module with a test_vfs_summary test view (page display at /test-vfs-summary with exposed title, type, and status filters).

FunctionalJavascript tests (5 test methods, 48 assertions)

Added tests/src/FunctionalJavascript/ViewsFiltersSummaryJsTest.php covering all JavaScript interactions:

  1. testSummaryRendersAndJsInitializes — navigates with active filter, verifies summary present, confirms JS removes the disabled class from remove links
  2. testRemoveTextFilter — applies title filter via exposed form, clicks X remove link, verifies filter removed after page reload
  3. testRemoveSelectFilter — applies type filter, verifies human-readable bundle label in summary, clicks X, verifies filter cleared
  4. testResetAllFilters — enables reset link, applies title + type filters, clicks Reset, verifies all filters cleared
  5. testAjaxRemoveFilter — enables AJAX on view, applies title filter, clicks X, verifies AJAX update without page reload (via Views DOM ID comparison)

Bug fix: missing core/once library dependency

During FunctionalJavascript test development, discovered that views_filters_summary.libraries.yml was missing core/once as a dependency. The JavaScript uses the once() function but did not declare this dependency. In production this usually works because other libraries (e.g. core/drupal.ajax) load core/once transitively. However, in minimal environments without AJAX, the once global is undefined and JavaScript initialization silently fails — the disabled class is never removed from remove/reset links, making them non-functional.

CI configuration

Updated .gitlab-ci.yml to run the new test suites.

  • mably committed 588a4855 on 3.x
    task: #3574008 Convert all hooks to OOP format and add tests
    
    By: mably
    
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.