Skip to content

Testing & CI: current setup is non-functional — proposal to restore automated checks #257

Description

@Martin-1997

Summary

The repository contains the scaffolding for automated tests, but in practice there are no working tests and no running CI. As the app takes on dependency and Nextcloud-version updates, this makes every change hard to verify and risky to merge. This issue documents the current state and proposes an incremental path to a working, low-maintenance safety net.

Current state

  • PHPUnit scaffolding exists but is empty of real tests. phpunit.xml, phpunit.integration.xml, and tests/bootstrap.php are present.
  • The only test is default template boilerplate. tests/Unit/Controller/PageControllerTest.php only asserts that the index page returns a TemplateResponse named index — it was generated by the Nextcloud app skeleton and tests none of the app's actual behaviour.
  • That single test can no longer run. It uses PHPUnit_Framework_TestCase and an untyped setUp(), which is PHPUnit 5-era syntax. It is incompatible with modern PHPUnit (class renamed in 6+, void return type required in 8+), so make test does not produce a passing baseline.
  • No coverage of the logic-heavy code. There are no tests for controllers, services, or the Db mappers — including the report query building, which is the most complex and most bug-prone part of the app (see the recent grouped-report / GROUP BY compatibility problem raised in fixes mtierltd/timetracker#234 #245).
  • CI is defunct. .travis.yml is pinned to PHP 5.6–7.1, Nextcloud stable14, and MariaDB 10.1. Travis CI's free open-source service has been shut down for years, so CI has not run in a very long time.
  • No GitHub Actions. There is no .github/workflows/ directory.
  • No JS test tooling. There is no package.json; the gulp/karma references in the Makefile are leftover template comments.

Why this matters

Incoming dependency bumps and Nextcloud max-version updates are, by nature, "does everything still work?" changes — exactly the kind of change automated checks verify cheaply and repeatedly. Without them, each such PR has to be validated by hand.

A concrete recent example: the change proposed in #245 would break grouped reports on PostgreSQL and on MySQL with ONLY_FULL_GROUP_BY (the modern default), because it selects a non-aggregated column under a GROUP BY. Nothing in the current repo would have caught that.

Proposed solutions (incremental, ordered by leverage)

  • 1. Restore CI with GitHub Actions (replace Travis). Start with the cheap, high-value checks that require almost no test-writing: php -l linting, composer validate/install, and static analysis (Psalm or PHPStan). Nextcloud publishes reusable workflow templates (in nextcloud/.github) that can largely be dropped in.
  • 2. Establish a green baseline. Modernise the existing test (PHPUnit\Framework\TestCase, setUp(): void) or replace it, so make test passes again and CI has something to run.
  • 3. Add targeted unit tests for the highest-risk logic first. Prioritise the Db mappers and report query building — the multi-database SQL where bugs are silent and engine-specific.
  • 4. Add integration tests against multiple databases (later). Spin up Nextcloud against SQLite, MySQL, and PostgreSQL to catch cross-database SQL issues like the GROUP BY case above. Higher setup cost, but the strongest guarantee for this app's SQL.
  • 5. (Optional, lower priority) Frontend JS tests, if/when a JS build and package.json are reintroduced. -> this will not be done because of Migrate the frontend to the Nextcloud UI framework (@nextcloud/vue) — staged epic #259

Suggested first step

Land a minimal green CI (lint + static analysis + PHPUnit) before merging the pending dependency-update PRs, so that every subsequent PR is checked automatically instead of by hand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions