Problem/Motivation
IndexNowPathProcessor and IndexNowOutboundPathProcessor
have no dedicated unit tests. Both are only exercised indirectly through kernel
tests, which leaves their core logic unverified in isolation:
-
IndexNowPathProcessor::processInbound()rewrites the public
/{key}.txtpath to the internal
/index_now_api_key/{key}route. The guard conditions (empty
key, path mismatch) are never explicitly asserted. -
IndexNowOutboundPathProcessor::processOutbound()overrides
$options['base_url']when theindex_nowoption
and theindex_now.base_urlsetting are both present. The
combinations where one condition is missing are not tested.
Proposed resolution
Add tests/src/Unit/PathProcessor/IndexNowPathProcessorTest.php
covering:
- Path is rewritten when the key matches.
- Path is returned unchanged when the key is empty.
- Path is returned unchanged when the path does not match the key.
Add tests/src/Unit/PathProcessor/IndexNowOutboundPathProcessorTest.php
covering:
-
base_urlis overridden when both theindex_now
option and theindex_now.base_urlsetting are set. - Trailing slash is stripped from the configured base URL.
-
base_urlis left unchanged when theindex_now
option is absent. -
base_urlis left unchanged whenabsoluteis not
set. -
base_urlis left unchanged whenindex_now.base_url
is not configured.
All dependencies (IndexNowKeyManagerInterface,
Settings) should be mocked or stubbed. No Drupal bootstrap is
required.
Remaining tasks
- [ ] Write
IndexNowPathProcessorTest.php - [ ] Write
IndexNowOutboundPathProcessorTest.php - [ ] Ensure all scenarios listed above pass
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork index_now-3587872
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
Comment #4
macsim commentedComment #6
macsim commented