From f7b03926b07ea700bf332fc004852e7c92c0df20 Mon Sep 17 00:00:00 2001 From: fs Date: Thu, 19 Mar 2026 20:22:10 +0100 Subject: [PATCH] Clarify test suite taxonomy --- phpunit.xml | 12 ++++++++ tests/README.md | 29 +++++++++++++++---- .../AddressBookAuthorizationPolicyTest.php | 7 ----- .../BookmarksAuthorizationPolicyTest.php | 7 ----- tests/Unit/Module/SessionProviderTest.php | 7 ----- 5 files changed, 36 insertions(+), 26 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 4e052f2..fd3b16c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -17,6 +17,18 @@ tests modules/*/tests + + tests/Unit + + + tests/Service + + + tests/Repository + + + tests/Domain + tests/Architecture diff --git a/tests/README.md b/tests/README.md index 3b43ac5..8dd80d7 100644 --- a/tests/README.md +++ b/tests/README.md @@ -9,6 +9,10 @@ ohne dass jede Aenderung immer die komplette Suite im Kopf behalten muss. ## PHPUnit-Suiten - `CoreCore`: gesamte Test-Suite. +- `Unit`: kleine verhaltensorientierte Unit-Tests ohne breites Orchestrierungs-Setup. +- `Service`: Business-Logik, Policies, Gateways und Orchestrierungs-Tests unter `tests/Service/`. +- `Repository`: Query- und Repository-Tests unter `tests/Repository/`. +- `Domain`: fachliche Taxonomie- und Domain-Tests unter `tests/Domain/`. - `Architecture`: alle Architektur-Contracts unter `tests/Architecture/`. - `ArchitectureCore`: Core-Boundaries, Module-/Repository-Contracts, Taxonomie- und Sync-Contracts. - `ArchitectureSecurity`: CSRF, PRG, File-Storage, Crypto, Logging sowie AuthZ-nahe Contracts. @@ -30,9 +34,24 @@ ohne dass jede Aenderung immer die komplette Suite im Kopf behalten muss. - `refactor`: Schutz ist wichtig, aber der Test ist zu datei-, markup- oder implementation-detailnah. - `delete`: dupliziert bestehende Schutzwirkung oder prueft nur historische Altlasten. -## Naechste Refactor-Kandidaten +## Regeln fuer neue Service-Tests -- `tests/Architecture/ContainerFactoryContractTest.php` -- `tests/Architecture/SecurityCryptoContractTest.php` -- `tests/Architecture/AuthzApiBootstrapContractTest.php` -- `tests/Architecture/ListUiSharedPartialsContractTest.php` +- Services auf Guards, Orchestrierung, Normalisierung, Fehlerpfade und Seiteneffekte testen. +- Keine eigenen Tests fuer reine `find/list/get/set`-Delegation ohne zusaetzliche Regel. +- Thin Wrapper auf gemeinsame Primitive zentral testen, nicht pro Gateway erneut. +- Mockability-, Reflection- und Interface-Existenz-Tests ohne Risiko-Schutz vermeiden. +- Kleine Normalisierungs-Matrizen mit DataProvidern oder zusammengezogenen Contract-Dateien verdichten. + +## Typische Low-Value-Muster + +- Gateway-Test prueft nur `encrypt/decrypt` erneut, obwohl das Basisverhalten schon zentral abgesichert ist. +- Test bestaetigt nur, dass ein Service eins zu eins an Repository oder Gateway weiterreicht. +- Test prueft nur Methodensignatur, Reflection oder dass eine Klasse mockbar ist. +- Mehrere Minidateien decken denselben Settings-/Fallback-Mechanismus mit identischem Mock-Muster ab. + +## Naechste Audit-Kandidaten + +- methodenweiser Low-value-Pass in `tests/Service/User/UserAccountServiceTest.php` +- methodenweiser Low-value-Pass in `tests/Service/Org/DepartmentServiceTest.php` +- methodenweiser Low-value-Pass in `tests/Service/Access/RoleServiceTest.php` +- verbleibende kleine Settings-Gateway-Tests auf weitere Verdichtung pruefen diff --git a/tests/Unit/Module/AddressBookAuthorizationPolicyTest.php b/tests/Unit/Module/AddressBookAuthorizationPolicyTest.php index f89628f..78d1b7b 100644 --- a/tests/Unit/Module/AddressBookAuthorizationPolicyTest.php +++ b/tests/Unit/Module/AddressBookAuthorizationPolicyTest.php @@ -3,7 +3,6 @@ namespace MintyPHP\Tests\Unit\Module; use MintyPHP\Module\AddressBook\AddressBookAuthorizationPolicy; -use MintyPHP\Service\Access\AuthorizationPolicyInterface; use MintyPHP\Service\Access\PermissionService; use MintyPHP\Tests\Service\Access\AuthorizationPolicyTestSupport; use PHPUnit\Framework\TestCase; @@ -15,12 +14,6 @@ final class AddressBookAuthorizationPolicyTest extends TestCase { use AuthorizationPolicyTestSupport; - public function testImplementsInterface(): void - { - $policy = new AddressBookAuthorizationPolicy($this->createMock(PermissionService::class)); - self::assertInstanceOf(AuthorizationPolicyInterface::class, $policy); - } - public function testSupportsOwnAbility(): void { $policy = new AddressBookAuthorizationPolicy($this->createMock(PermissionService::class)); diff --git a/tests/Unit/Module/BookmarksAuthorizationPolicyTest.php b/tests/Unit/Module/BookmarksAuthorizationPolicyTest.php index a84c929..9eeb58e 100644 --- a/tests/Unit/Module/BookmarksAuthorizationPolicyTest.php +++ b/tests/Unit/Module/BookmarksAuthorizationPolicyTest.php @@ -3,17 +3,10 @@ namespace MintyPHP\Tests\Unit\Module; use MintyPHP\Module\Bookmarks\BookmarksAuthorizationPolicy; -use MintyPHP\Service\Access\AuthorizationPolicyInterface; use PHPUnit\Framework\TestCase; final class BookmarksAuthorizationPolicyTest extends TestCase { - public function testImplementsAuthorizationPolicyContract(): void - { - $policy = new BookmarksAuthorizationPolicy(); - self::assertInstanceOf(AuthorizationPolicyInterface::class, $policy); - } - public function testSupportsBookmarksAbilityOnly(): void { $policy = new BookmarksAuthorizationPolicy(); diff --git a/tests/Unit/Module/SessionProviderTest.php b/tests/Unit/Module/SessionProviderTest.php index 8a75e5e..d4e1995 100644 --- a/tests/Unit/Module/SessionProviderTest.php +++ b/tests/Unit/Module/SessionProviderTest.php @@ -3,7 +3,6 @@ namespace MintyPHP\Tests\Unit\Module; use MintyPHP\App\AppContainer; -use MintyPHP\App\Module\Contracts\SessionProvider; use MintyPHP\Module\AddressBook\Providers\AddressBookSessionProvider; use PHPUnit\Framework\TestCase; @@ -31,12 +30,6 @@ final class SessionProviderTest extends TestCase return new AppContainer(); } - public function testImplementsSessionProviderContract(): void - { - $provider = new AddressBookSessionProvider(); - self::assertInstanceOf(SessionProvider::class, $provider); - } - public function testPopulateWithInvalidUserClearsSessionKey(): void { $_SESSION['module.addressbook.departments_by_tenant'] = [['tenant' => 'old']];