Skip to content

Broken: 21 unit tests fail due to ObjectService stub/real-signature mismatch #90

@rubenvdlinde

Description

@rubenvdlinde

Summary

When the decidesk unit-test suite runs in an environment where OpenRegister is installed (e.g. the Nextcloud container or CI with the server bootstrapped), the real `OCA\OpenRegister\Service\ObjectService` class is loaded by Nextcloud's autoloader — bypassing the stub fallback in `tests/bootstrap*.php`.

The decidesk tests mock `saveObject`, `find`, `getObject`, and `findObjects` assuming the stub signature (`?array` returns). The real `ObjectService` has different return types (`ObjectEntity`) and, for `findObjects`, no method of that name at all.

Under PHPUnit 10 this surfaces as:

  • `PHPUnit\Framework\MockObject\IncompatibleReturnValueException: Method saveObject may not return value of type array, its declared return type is `OCA\OpenRegister\Db\ObjectEntity``
  • `PHPUnit\Framework\MockObject\MethodCannotBeConfiguredException: Trying to configure method `findObjects` which cannot be configured because it does not exist`

21 tests error out, blocking the Hydra pipeline builder on every spec.

Failing tests

  • `tests/Unit/Controller/DecisionControllerTest`: 1 test
  • `tests/Unit/Service/MeetingServiceTest`: 3 tests
  • `tests/Unit/Service/MotionServiceTest`: 7 tests
  • `tests/Unit/Service/VotingServiceTest`: 10 tests

Short-term workaround (this PR)

Mark the 21 affected tests with `markTestSkipped()` so the suite can run green in the container.

Proposed long-term fix

Pick one approach and apply it consistently:

  1. Align stubs to real `ObjectService` — update `tests/Stubs/Service/ObjectService.php` to mirror the real class's method list and return types (`saveObject(...): ObjectEntity`, `find(...): ?ObjectEntity`, no `findObjects`, use `searchObjectsPaginated` instead). Then update every test that sets return values to produce `ObjectEntity` mocks (or a simple stub implementing the required interface shape).
  2. Decouple tests from the real class — make the unit-test bootstrap actively unregister any autoloader that resolves `OCA\OpenRegister\Service\ObjectService` to the real class, then include the stub. This is fragile but preserves the current test style.
  3. Rewrite production code to depend on a thin adapter interface in the decidesk namespace rather than OpenRegister's `ObjectService` directly. The tests mock the adapter, not `ObjectService`. This is the cleanest but also the largest change.

Option 1 is recommended — align the stub with reality, then retrofit the tests.

Priority

High — same blast radius as pipelinq #286 (same class of pattern in a sibling repo).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions