Skip to content

Test suite: remove duplicate, fix namespaces/typos, add missing unit tests (#539)#551

Open
maltehuebner wants to merge 1 commit into
mainfrom
improve/testsuite-539
Open

Test suite: remove duplicate, fix namespaces/typos, add missing unit tests (#539)#551
maltehuebner wants to merge 1 commit into
mainfrom
improve/testsuite-539

Conversation

@maltehuebner

Copy link
Copy Markdown
Contributor

Addresses the verifiable, unit-level items of #539.

Changes

Structure & quality

  • Removed the duplicated PollutantViewModelTest at the stale path tests/Pollutant/ViewModel/ (there is no matching src/Pollutant/; the tests/Air/... copy mirrors src/Air/ViewModel/). Its one unique case, testPollutionLevel, was ported into the kept file so coverage is preserved.
  • Fixed the PSR-4 violation in tests/Controller/ControllerTest.php (declared namespace App\Tests\Controller\Api; while living in tests/Controller/) → App\Tests\Controller.
  • Removed the $client = $client = static::createClient(); copy-paste typos (3× in ControllerTest, 1× in ApiControllerTest).
  • Assertions: assertSame for identity/value equality, and assertEqualsWithDelta(..., 0.01) for the computed float in DistanceCalculatorTest (previously relied on the implementation's round()).

New unit tests (previously 0 coverage)

  • ValueDataConverterTest — the pollutant-identifier mapping edge cases from the issue: known identifier, case-insensitivity, underscore stripping (UV_INDEX_MAXuvindexmax), and unknown → null (via reflection on the protected static convertPollutant).
  • UVIndexMaxTest and UVIndexMaxLevelTest — the UVIndexMax / UVIndexMaxLevel gap explicitly called out in the issue.

Deliberately not implemented / deferred

  • Activating the Integration suite in CI. Requires PostGIS + Redis service containers, a DB schema (explicitly depends on the migrations issue) and a bootable kernel. The container cannot be booted in this environment (local vendor/ lacks symfony/runtime, so WebTestCase cannot start), so this cannot be built or verified here.
  • Decoupling testImpressPage from the network (config/packages/impress.yaml uses source: remote_json). A test-env override is a config change that needs a kernel boot to verify; deferred with the CI-integration work.
  • EntityMerger tests. Its three confirmed bugs are tracked in [Hoch] Mass Assignment im EntityMerger + wirkungsloser #[Ignore]-Check #523 and being fixed separately; writing tests that assert the corrected behaviour here would either duplicate that work or turn the suite red against current main. Left to accompany the [Hoch] Mass Assignment im EntityMerger + wirkungsloser #[Ignore]-Check #523 fix.
  • RequestConverter / deserializeRequestBodyToArray / StationCache tests. These need a geocoder mock/kernel/DB or touch code covered by the 500-route/[Hoch] Mass Assignment im EntityMerger + wirkungsloser #[Ignore]-Check #523 issues; deferred.

Verification

  • vendor/bin/phpunit --testsuite="Project Test Suite" — OK (129 tests, was 121)
  • vendor/bin/phpstan analyse --no-progress — No errors
  • The Controller-test edits (namespace/typo/assertSame) are static and safe but live in the Integration suite, which is not runnable locally here.

Refs #539 (partial)

🤖 Generated with Claude Code

Structural/quality fixes from the test-suite audit:

- Remove the duplicated PollutantViewModelTest at the stale path
  tests/Pollutant/ViewModel/; keep the tests/Air/... copy (mirrors
  src/Air/) and port its unique testPollutionLevel case so no coverage
  is lost.
- Fix the PSR-4 violation in tests/Controller/ControllerTest.php
  (declared namespace App\Tests\Controller\Api while living in
  tests/Controller/) -> App\Tests\Controller.
- Remove the "$client = $client = ..." copy-paste typos in
  ControllerTest and ApiControllerTest.
- Use assertSame for identity/value equality and assertEqualsWithDelta
  for the computed float in DistanceCalculatorTest.

New unit tests for previously uncovered classes:

- ValueDataConverter: pollutant-identifier mapping incl. case-
  insensitivity, underscore stripping (UV_INDEX_MAX) and unknown ->
  null.
- UVIndexMax pollutant and UVIndexMaxLevel (the gap called out in the
  issue).

Project Test Suite: 129 tests (was 121), all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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