🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

test: add Kernel coverage for JsonapiViews display extender - #9

Merged
Decipher merged 3 commits into
8.x-1.xfrom
test/kernel-coverage-views-resource
Aug 3, 2026
Merged

test: add Kernel coverage for JsonapiViews display extender#9
Decipher merged 3 commits into
8.x-1.xfrom
test/kernel-coverage-views-resource

Conversation

@Decipher

@Decipher Decipher commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds testDisplayExtenderOptionsForm() to JsonapiViewsResourceKernelTest, covering JsonapiViews::buildOptionsForm(), submitOptionsForm(), and optionsSummary() (previously untested admin-form methods).
  • Fixes phpstan.neon's rector.php exclusion glob, which never matched the nested build path, and drops a now-deprecated Rector rule from rector.php's withSkip() that PHPStan started flagging as a result.

Test plan

  • make lint clean on both DRUPAL_VERSION=10 and DRUPAL_VERSION=11
  • Full Kernel test suite (5 tests, 91 assertions) passing on both D10 and D11
  • gitlab.local pipeline green (MR !2)

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability for JSON:API Views page displays, including pagination and cache metadata.
    • Ensured disabled displays correctly return access-denied responses.
    • Improved handling of attachment displays, exposed filters, and sorting.
    • Improved display extender configuration behavior.
  • Tests

    • Added comprehensive coverage for JSON:API Views functionality and access controls.

JsonapiViewsResourceTest (Functional) exercises ViewsResource thoroughly
but makes real HTTP requests against a PHP subprocess, so PHPUnit's
coverage driver never sees that execution - measured coverage for
src/Resource/ViewsResource.php was 6.32% (5/79 lines) despite the
functional coverage.

Adds a Kernel test that dispatches requests through the HTTP kernel
in-process (Symfony\Component\HttpKernel\HttpKernelInterface::handle(),
reusing jsonapi_resources' own RequestTrait pattern), so the same
request/response cycle is now visible to coverage tooling. Covers:

- Page display pagination (both the 'next' and 'prev' link branches in
  ViewsResource::getViewsPager())
- The unexposed-display 403 early-return branch (feed_1's
  display_extenders.jsonapi_views.enabled=false)
- The attachment display's hard-coded filter
- Exposed filter and sort query parameters

Kernel-test module enabling skips module install hooks, so
jsonapi_views_install()'s registration of the jsonapi_views display
extender into views.settings.display_extenders never runs; the test
sets that config directly in setUp() to compensate.
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8549adab-9d65-4c64-89e9-cc0f3aa07131

📥 Commits

Reviewing files that changed from the base of the PR and between 1eb010e and a5dcad6.

📒 Files selected for processing (3)
  • phpstan.neon
  • rector.php
  • tests/src/Kernel/JsonapiViewsResourceKernelTest.php
💤 Files with no reviewable changes (1)
  • rector.php

📝 Walkthrough

Walkthrough

The pull request adds kernel tests for JSON:API Views pagination, access control, attachments, exposed filters, sorting, and display extender forms. It also updates PHPStan path matching and removes one skipped Rector rule.

Changes

JSON:API Views kernel tests

Layer / File(s) Summary
Kernel setup and endpoint behavior
tests/src/Kernel/JsonapiViewsResourceKernelTest.php
Adds kernel setup, authenticated requests, and coverage for pagination, cache contexts, disabled displays, attachments, exposed filters, and sorting.
Display extender options form tests
tests/src/Kernel/JsonapiViewsResourceKernelTest.php
Tests section-specific form building, submission behavior, and the options summary.

Tooling configuration

Layer / File(s) Summary
PHPStan and Rector configuration
phpstan.neon, rector.php
Updates the rector.php exclusion to support prefixed paths and removes CountArrayToEmptyArrayComparisonRector from skipped rules.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding Kernel coverage for the JsonapiViews display extender.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/kernel-coverage-views-resource

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.11%. Comparing base (1eb010e) to head (a5dcad6).
⚠️ Report is 1 commits behind head on 8.x-1.x.

Additional details and impacted files
@@             Coverage Diff              @@
##           8.x-1.x       #9       +/-   ##
============================================
+ Coverage    30.14%   94.11%   +63.97%     
============================================
  Files            3        3               
  Lines          136      136               
============================================
+ Hits            41      128       +87     
+ Misses          95        8       -87     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Decipher
Decipher merged commit 3e50d79 into 8.x-1.x Aug 3, 2026
11 checks passed
@Decipher
Decipher deleted the test/kernel-coverage-views-resource branch August 3, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant