Skip to content

fix(tests): opt into the OpenRegister contract instead of relying on a claimed prefix - #696

Merged
rubenvdlinde merged 1 commit into
developmentfrom
fix/contract-opt-in-guard
Aug 22, 2026
Merged

fix(tests): opt into the OpenRegister contract instead of relying on a claimed prefix#696
rubenvdlinde merged 1 commit into
developmentfrom
fix/contract-opt-in-guard

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Prepares this app for ConductionNL/.github#531, which drops OCA\OpenRegister\Contract\ from hydra-gates runtime psr-4 autoload.

That prefix is longer than openregister own OCA\OpenRegister\ to lib/, and PSR-4 is longest-prefix-wins, so whichever app autoloader registers first defines OpenRegister contract for the whole process.

Why a guard, not a fallback autoloader

spl_autoload_register appends relative to registration order, and that order across independently loaded apps is exactly what nobody controls. interface_exists() asks whether the interface is resolvable, which is order-independent.

Safe to land now, this is a no-op while hydra-gates still declares the prefix.

This one also fixes a LIVE problem

tests/bootstrap-unit.php registers its OpenRegister stubs through a manual spl_autoload_register prefix map covering OCA\OpenRegister\Db\ and ...\Service\. Neither covers ...\Contract\, so the standalone unit suite was already failing on it:

state result
before Tests: 715, Assertions: 2573, Errors: 131, Failures: 1
after Tests: 715, Assertions: 2993, Errors: 1, Failures: 0

The single remaining error is unrelated (Symfony\Component\HttpFoundation\HeaderUtils absent from the standalone environment, reached via OCP DownloadResponse).

Added to BOTH bootstraps: phpunit.xml loads tests/bootstrap.php and phpunit-unit.xml loads tests/bootstrap-unit.php. The full phpunit.xml path cannot be measured outside a Nextcloud tree (its bootstrap fatals on Class "OC_App" not found), so that half is verified by CI.

… unit errors

Prepares this app for ConductionNL/.github#531, which drops
`OCA\OpenRegister\Contract\` from conduction/hydra-gates' RUNTIME psr-4
autoload. That prefix is LONGER than openregister's own `OCA\OpenRegister\` ->
`lib/`, and PSR-4 is longest-prefix-wins, so whichever app's autoloader
registers first defines OpenRegister's contract for the whole process.

IT ALSO FIXES A LIVE PROBLEM HERE, WHICH THE OTHER APPS IN THIS SWEEP DID NOT
HAVE. tests/bootstrap-unit.php registers its OpenRegister stubs through a manual
spl_autoload_register prefix map covering `OCA\OpenRegister\Db\` and
`...\Service\`. Neither covers `...\Contract\`, so the standalone unit suite was
already failing on it:

  before   Tests: 715, Assertions: 2573, Errors: 131, Failures: 1, Skipped: 25
  after    Tests: 715, Assertions: 2993, Errors: 1,   Failures: 0, Skipped: 24

The single remaining error is unrelated — Symfony\Component\HttpFoundation\
HeaderUtils is absent from the standalone environment, reached via OCP's
DownloadResponse.

Added to BOTH bootstraps deliberately: phpunit.xml loads tests/bootstrap.php and
phpunit-unit.xml loads tests/bootstrap-unit.php, and both reach code that needs
the contract. The full phpunit.xml path cannot be measured outside a Nextcloud
tree (its bootstrap fatals on `Class "OC_App" not found`), so that half is
verified by CI rather than locally, and is a no-op there while the prefix still
exists.

interface_exists() is order-independent: it asks whether the interface is
RESOLVABLE rather than who registered first. Appending a fallback autoloader
does not work, because spl_autoload_register appends relative to registration
order and that order across independently loaded apps is what nobody controls.
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/stackiq @ 3088f5f

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
build
check-manifest
check-vue-demi
test-l10n
format
composer ✅ 130/130
npm ✅ 703/703
app:check-code ⏭️
info.xml
REUSE
PHPUnit
Newman ⏭️
Playwright
Hydra gates

Quality workflow — 2026-08-22 00:11 UTC

Download the full PDF report from the workflow artifacts.

@rubenvdlinde
rubenvdlinde merged commit 646c301 into development Aug 22, 2026
81 checks passed
@rubenvdlinde
rubenvdlinde deleted the fix/contract-opt-in-guard branch August 22, 2026 00:16
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