feat: PHPUnit Test-Infrastruktur und Router-Tests #64

Merged
greggy merged 2 commits from feature/phpunit-tests into main 2026-05-22 21:33:32 +02:00
Owner

Zusammenfassung

Fügt PHPUnit-Test-Infrastruktur hinzu und legt erste Unit-Tests für App\Core\Router an.

Änderungen

  • composer.json – PHPUnit 11 + PSR-4 Autoloading
  • phpunit.xml – Test-Konfiguration (Unit Suite, Code Coverage)
  • app/core/ → app/Core/ – PSR-4 konforme Verzeichnisnamen
  • app/controllers/ → app/Controllers/ – PSR-4 konforme Verzeichnisnamen
  • tests/Core/RouterTest.php – 18 Unit-Tests (31 Assertions)
  • .gitignorevendor/ und .phpunit.cache/ hinzugefügt

Test-Abdeckung (Router)

Bereich Tests
addRoute() Default-Action, Custom-Action, Overwrite
dispatch() – URL-Normalisierung Query-String, Trailing-Slash, Root-Path
dispatch() – Direct Match Route-Ausführung, Custom Action
dispatch() – Legacy Redirects impressum.html, datenschutz.html, Non-Matches (Data Provider)
dispatch() – Fehlerbehandlung 404, Controller nicht gefunden, Action nicht gefunden
dispatch() – Controller-Invocation Erfolgreiche Ausführung mit Output-Capture

Test-Ergebnis

OK (18 tests, 31 assertions)

Annahmen

  • TestableRouter als Subclass fängt header()/exit()/echo-Side-Effects ab
  • DummyController als Minimal-Controller zum Testen von dispatch
  • Keine echten DB-Verbindungen, keine Integrationstests
## Zusammenfassung Fügt PHPUnit-Test-Infrastruktur hinzu und legt erste Unit-Tests für `App\Core\Router` an. ## Änderungen - **composer.json** – PHPUnit 11 + PSR-4 Autoloading - **phpunit.xml** – Test-Konfiguration (Unit Suite, Code Coverage) - **app/core/ → app/Core/** – PSR-4 konforme Verzeichnisnamen - **app/controllers/ → app/Controllers/** – PSR-4 konforme Verzeichnisnamen - **tests/Core/RouterTest.php** – 18 Unit-Tests (31 Assertions) - **.gitignore** – `vendor/` und `.phpunit.cache/` hinzugefügt ## Test-Abdeckung (Router) | Bereich | Tests | |---|---| | `addRoute()` | Default-Action, Custom-Action, Overwrite | | `dispatch()` – URL-Normalisierung | Query-String, Trailing-Slash, Root-Path | | `dispatch()` – Direct Match | Route-Ausführung, Custom Action | | `dispatch()` – Legacy Redirects | impressum.html, datenschutz.html, Non-Matches (Data Provider) | | `dispatch()` – Fehlerbehandlung | 404, Controller nicht gefunden, Action nicht gefunden | | `dispatch()` – Controller-Invocation | Erfolgreiche Ausführung mit Output-Capture | ## Test-Ergebnis ``` OK (18 tests, 31 assertions) ``` ### Annahmen - `TestableRouter` als Subclass fängt `header()`/`exit()`/`echo`-Side-Effects ab - `DummyController` als Minimal-Controller zum Testen von dispatch - Keine echten DB-Verbindungen, keine Integrationstests
greggy added 1 commit 2026-05-22 21:09:38 +02:00
feat: add PHPUnit test infrastructure and Router tests
All checks were successful
Deploy Feature Branch to Test / deploy (push) Successful in 28s
Lint / PHP Syntax Check (push) Successful in 36s
Lint / CSS Lint (stylelint) (push) Successful in 1m18s
Lint / HTML Lint (htmlhint) (push) Successful in 1m11s
Lint / PHP Syntax Check (pull_request) Successful in 37s
Lint / CSS Lint (stylelint) (pull_request) Successful in 1m20s
Lint / HTML Lint (htmlhint) (pull_request) Successful in 1m13s
57b97b5069
- Add composer.json with PHPUnit 11 and PSR-4 autoloading
- Add phpunit.xml configuration
- Rename app/core/ → app/Core/ and app/controllers/ → app/Controllers/ (PSR-4)
- Add 18 unit tests for App\Core\Router (31 assertions)
  - addRoute(): default action, custom action, overwrite
  - dispatch(): URL normalization, direct match, legacy redirects
  - dispatch(): 404 handling, controller/action not found exceptions
  - TestableRouter subclass to intercept side-effects
- Update .gitignore (vendor/, .phpunit.cache/)
greggy added 1 commit 2026-05-22 21:19:41 +02:00
fix: replace custom autoloader with composer PSR-4 autoloader
All checks were successful
Deploy Feature Branch to Test / deploy (push) Successful in 29s
Lint / PHP Syntax Check (push) Successful in 37s
Lint / CSS Lint (stylelint) (push) Successful in 1m17s
Lint / HTML Lint (htmlhint) (push) Successful in 1m15s
Lint / PHP Syntax Check (pull_request) Successful in 32s
Lint / CSS Lint (stylelint) (pull_request) Successful in 1m12s
Lint / HTML Lint (htmlhint) (pull_request) Successful in 1m8s
3a30abc05e
The custom autoloader used lowercase directory names which broke
after renaming app/core/ → app/Core/ and app/controllers/ → app/Controllers/
for PSR-4 compliance.
greggy merged commit 1a72210608 into main 2026-05-22 21:33:32 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: greggy/landingpage-haus-schleusingen#64
No description provided.