Auto-commit: 2026-05-24 19:58
This commit is contained in:
@@ -147,6 +147,19 @@ Nach dem Merge durch Martin MÜSSEN Phase 6 und 7 automatisch weiterlaufen.
|
||||
## Regeln
|
||||
- Phase 1 filtert auf **nur** `KI`
|
||||
- Ab Phase 2: **nur** Issues mit `KI` + `ReadyForDev`
|
||||
- **Label `KI` maximal 1× pro Issue hinzufügen** — vorher immer prüfen ob das Label bereits existiert:
|
||||
```bash
|
||||
# Prüfe ob Label "KI" bereits gesetzt ist
|
||||
HAS_KI=$(curl -s "https://git.home.kies-media.de/api/v1/repos/<owner>/<repo>/issues/<number>" \
|
||||
-u "$GIT_USER:$GIT_PASS" | jq '[.labels[] | select(.name=="KI")] | length > 0')
|
||||
if [ "$HAS_KI" != "true" ]; then
|
||||
# Erst dann hinzufügen
|
||||
curl -s -X POST "https://git.home.kies-media.de/api/v1/repos/<owner>/<repo>/issues/<number>/labels" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"labels": ["KI"]}'
|
||||
fi
|
||||
```
|
||||
- **Nie** ohne Martins Freigabe mergen
|
||||
- **Nie** Issue selbst schließen (nur Phase 7 darf das)
|
||||
- **Nie** direkt auf `main` pushen
|
||||
|
||||
70
skills/phpunit-tests/SKILL.md
Normal file
70
skills/phpunit-tests/SKILL.md
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
name: phpunit-tests
|
||||
description: >
|
||||
Generate high-quality PHPUnit unit tests for small MVC PHP applications (no framework).
|
||||
Use when: (1) PHP classes need test coverage, (2) user asks to generate unit tests,
|
||||
(3) code review reveals missing tests, (4) "PHPUnit", "unit tests", "test coverage" mentioned for PHP code.
|
||||
Targets PHP 8.2+, strict types, PHPUnit only. All dependencies mocked. No integration tests.
|
||||
---
|
||||
|
||||
# PHPUnit Test Generation
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
app/
|
||||
Controllers/
|
||||
Models/
|
||||
Services/
|
||||
Repositories/
|
||||
Helpers/
|
||||
tests/
|
||||
```
|
||||
|
||||
No heavy framework (no Laravel, Symfony, CodeIgniter). Pure PHP-MVC.
|
||||
|
||||
## Test Rules
|
||||
|
||||
- PHPUnit only. Real unit tests. No integration tests.
|
||||
- No real database connections. No real HTTP requests.
|
||||
- Always mock or stub external dependencies. Never mock the class under test.
|
||||
- Tests must be independent. Each test checks exactly one behavior.
|
||||
- AAA pattern: Arrange → Act → Assert.
|
||||
- Descriptive method names: `testReturnsUserWhenIdExists`, `testThrowsExceptionWhenPasswordInvalid`.
|
||||
- Small, readable, deterministic tests. No global state. No random values without fixed seeds.
|
||||
|
||||
## Code Standards
|
||||
|
||||
- PHP >= 8.2, typed properties, `declare(strict_types=1)`.
|
||||
- Modern PHPUnit syntax. No deprecated APIs.
|
||||
- No unnecessary comments. No reflection. No magic.
|
||||
- PSR-compliant. Copy-paste runnable. Production-ready.
|
||||
|
||||
## Mocking
|
||||
|
||||
- Use PHPUnit mock objects for direct dependencies only.
|
||||
- Define mock behavior explicitly. Validate method calls when meaningful.
|
||||
- Services → mock repository dependencies.
|
||||
- Controllers → simulate HTTP input.
|
||||
- Helpers → test pure function logic.
|
||||
|
||||
## Output Format
|
||||
|
||||
1. Brief analysis of the class under test.
|
||||
2. List of relevant test cases.
|
||||
3. Complete PHPUnit test code (directly runnable).
|
||||
4. If needed: mock setup, test fixtures, data providers.
|
||||
|
||||
## Complex Logic
|
||||
|
||||
- List test cases first, then write tests.
|
||||
- Test edge cases for validation logic.
|
||||
- Always explicitly check exceptions.
|
||||
- If information is missing: make reasonable assumptions and document them briefly before the test code.
|
||||
|
||||
## Anti-Patterns
|
||||
|
||||
- One giant test for everything.
|
||||
- Too many assertions per test.
|
||||
- Hidden side effects.
|
||||
- Framework-specific test helpers.
|
||||
Reference in New Issue
Block a user