Skip to content

fix: Fix PHPUnit tests for CI - #190

Closed
rubenvdlinde wants to merge 9 commits into
developmentfrom
fix/phpunit-tests
Closed

fix: Fix PHPUnit tests for CI#190
rubenvdlinde wants to merge 9 commits into
developmentfrom
fix/phpunit-tests

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Summary

  • Replace createMock(ObjectEntity) with getMockBuilder()->addMethods() for Entity __call() magic methods
  • Fix ContactpersonenController and ContactPersonHandler constructor argument order/count
  • Remove integration tests from phpunit.xml (they need a running server, covered by Newman)
  • Migrate phpunit.xml to PHPUnit 10 format

Test plan

  • PHPUnit CI job passes (unit tests only)
  • Integration tests still available via --testsuite "Integration Tests" locally

@github-actions

Copy link
Copy Markdown
Contributor

Quality Report

Check Result
Composer Audit PASS success
npm Audit PASS success
PHP Lint PASS success
PHPCS FAIL failure
PHPMD PASS success
Psalm PASS success
PHPStan PASS success
phpmetrics PASS success
ESLint FAIL failure
Stylelint FAIL failure
PHPUnit Tests SKIP skipped
Integration Tests SKIP skipped
Coverage Baseline SKIP skipped

See workflow run for details.

- Migrate code-quality.yml to ConductionNL reusable quality workflow
- Replace createMock(ObjectEntity) with getMockBuilder()->addMethods() for __call magic methods
- Fix ContactpersonenController mock constructor argument order (add IUserSession, ContainerInterface)
- Fix ContactPersonHandler mock constructor (9 args instead of 4)
- Remove integration tests from phpunit.xml (need running server, belong in Newman)
- Make bootstrap.php resilient to missing Nextcloud environment
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report

Check Result
Composer Audit PASS success
npm Audit PASS success
PHP Lint PASS success
PHPCS SKIP skipped
PHPMD PASS success
Psalm PASS success
PHPStan PASS success
phpmetrics PASS success
ESLint FAIL failure
Stylelint FAIL failure
PHPUnit Tests FAIL failure
Integration Tests FAIL failure
Coverage Baseline SKIP skipped

See workflow run for details.

- Split ObjectEntity mock methods: onlyMethods for real methods (getObject),
  addMethods for magic __call methods (getSchema, getId, etc.)
- Delete EmailServiceTest (EmailService class doesn't exist)
- Fix testHandleEventWithNullObject to use mock instead of null
- Fix testPasswordChangeWithInvalidUser broken mock expectation
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report

Check Result
Composer Audit PASS success
npm Audit PASS success
PHP Lint PASS success
PHPCS SKIP skipped
PHPMD PASS success
Psalm PASS success
PHPStan PASS success
phpmetrics PASS success
ESLint FAIL failure
Stylelint FAIL failure
PHPUnit Tests FAIL failure
Integration Tests FAIL failure
Coverage Baseline SKIP skipped

See workflow run for details.

- jsonSerialize exists on ObjectEntity (via parent), move to onlyMethods
- Split testAddUserToGroupWithCheck into two tests to fix mock expectation conflict
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report

Check Result
Composer Audit PASS success
npm Audit PASS success
PHP Lint PASS success
PHPCS SKIP skipped
PHPMD PASS success
Psalm PASS success
PHPStan PASS success
phpmetrics PASS success
ESLint FAIL failure
Stylelint FAIL failure
PHPUnit Tests FAIL failure
Integration Tests FAIL failure
Coverage Baseline SKIP skipped

See workflow run for details.

The workflow helper methods set up expects(once()) on mocks but never invoke
the actual controller/service methods, causing guaranteed failures.
Changed to method() (no call count expectation) since the mocks serve as
data stubs for the assertion helpers.
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report

Check Result
Composer Audit PASS success
npm Audit PASS success
PHP Lint PASS success
PHPCS SKIP skipped
PHPMD PASS success
Psalm PASS success
PHPStan PASS success
phpmetrics PASS success
ESLint FAIL failure
Stylelint FAIL failure
PHPUnit Tests PASS success
Integration Tests FAIL failure
Coverage Baseline SKIP skipped

See workflow run for details.

@github-actions

Copy link
Copy Markdown
Contributor

Quality Report

Check Result
Composer Audit PASS success
npm Audit PASS success
PHP Lint PASS success
PHPCS SKIP skipped
PHPMD PASS success
Psalm PASS success
PHPStan PASS success
phpmetrics PASS success
ESLint FAIL failure
Stylelint FAIL failure
PHPUnit Tests PASS success
Integration Tests SKIP skipped
Coverage Baseline SKIP skipped

See workflow run for details.

@rubenvdlinde
rubenvdlinde changed the base branch from main to development March 19, 2026 09:42
@rubenvdlinde

Copy link
Copy Markdown
Contributor Author

Closing: the CI workflow change is superseded by #193 (reusable quality workflow, already merged). The PHPUnit mock fixes (createMock → getMockBuilder for ObjectEntity magic methods) are valuable but have too many conflicts against current development. These will be redone on a fresh cleanup branch.

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.

3 participants