feat(07-pre-expansion-fixes): complete phase 07 — milestone v0.2 done
Phase 7 complete (5 plans): - 07-01: Performance (N+1→LEFT JOIN, static cache, DB indexes) - 07-02: Stability (SSL verification, cron throttle DB, migration 000014b) - 07-03: UX (orderpro_to_allegro disable, lista zamówień fixes, SSL hotfix) - 07-04: Tests (12 unit tests for AllegroTokenManager + AllegroOrderImportService) - 07-05: InPost ShipX API (natywny provider, workaround remap usunięty) Additional fixes: - 5 broken use-statements fixed across 4 files - vendor/ excluded from ftp-kr auto-upload - PHPUnit + dg/bypass-finals infrastructure Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
164
.paul/phases/07-pre-expansion-fixes/07-04-SUMMARY.md
Normal file
164
.paul/phases/07-pre-expansion-fixes/07-04-SUMMARY.md
Normal file
@@ -0,0 +1,164 @@
|
||||
---
|
||||
phase: 07-pre-expansion-fixes
|
||||
plan: 04
|
||||
subsystem: testing
|
||||
tags: [phpunit, allegro, oauth, unit-tests, bypass-finals]
|
||||
|
||||
requires:
|
||||
- phase: 01-allegro-token-manager
|
||||
provides: AllegroTokenManager extracted class
|
||||
- phase: 07-pre-expansion-fixes
|
||||
provides: Plans 01-03 bug fixes stabilizing tested classes
|
||||
|
||||
provides:
|
||||
- 7 unit tests for AllegroTokenManager (token refresh logic)
|
||||
- 5 unit tests for AllegroOrderImportService (import + 401 retry)
|
||||
- PHPUnit infrastructure (composer dependencies, bypass-finals)
|
||||
- 3 use-statement bug fixes discovered by tests
|
||||
|
||||
affects: [07-05-inpost, future-refactoring, ci-cd]
|
||||
|
||||
tech-stack:
|
||||
added: [phpunit/phpunit 11.5, dg/bypass-finals 1.9]
|
||||
patterns: [bypass-finals for final class mocking, createMock with DI]
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- tests/Unit/AllegroTokenManagerTest.php
|
||||
- tests/Unit/AllegroOrderImportServiceTest.php
|
||||
modified:
|
||||
- tests/bootstrap.php
|
||||
- src/Modules/Settings/AllegroTokenManager.php
|
||||
- src/Modules/Settings/AllegroIntegrationRepository.php
|
||||
- src/Modules/Settings/AllegroOrderImportService.php
|
||||
|
||||
key-decisions:
|
||||
- "dg/bypass-finals zamiast usuwania final z klas produkcyjnych"
|
||||
- "Naprawienie 3 bugów use-statement odkrytych przez testy (nie przez plan)"
|
||||
|
||||
patterns-established:
|
||||
- "Testy unit: tests/Unit/{ClassName}Test.php z createMock + bypass-finals"
|
||||
- "bootstrap.php: DG\\BypassFinals::enable() dla wszystkich testów"
|
||||
|
||||
duration: ~15min
|
||||
completed: 2026-03-15T12:00:00Z
|
||||
---
|
||||
|
||||
# Phase 7 Plan 04: Unit Tests Summary
|
||||
|
||||
**12 testów jednostkowych dla AllegroTokenManager (7) i AllegroOrderImportService (5), plus 3 naprawione bugi use-statement odkryte przez testy.**
|
||||
|
||||
## Performance
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Duration | ~15min |
|
||||
| Completed | 2026-03-15 |
|
||||
| Tasks | 2 completed |
|
||||
| Files created | 2 |
|
||||
| Files modified | 4 |
|
||||
| Tests | 12 |
|
||||
| Assertions | 49 |
|
||||
|
||||
## Acceptance Criteria Results
|
||||
|
||||
| Criterion | Status | Notes |
|
||||
|-----------|--------|-------|
|
||||
| AC-1: AllegroTokenManager — logika refresh pokryta testami | Pass | 7 testów: fresh token, <5min, expired, no config, empty token, re-read, invalid format |
|
||||
| AC-2: AllegroOrderImportService — import happy path pokryty | Pass | 5 testów: happy path, 401 retry, empty ID, non-401 error, re-import |
|
||||
| AC-3: Wszystkie nowe testy przechodzą | Pass | 12 tests, 49 assertions, 0 failures |
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- 7 testów AllegroTokenManager pokrywających: świeży token (brak refresh), wygasający <5min, wygasły, brak konfiguracji OAuth, pusty access token, write-then-re-read, nieprawidłowy format daty
|
||||
- 5 testów AllegroOrderImportService pokrywających: happy path import, 401 retry, pusty ID, propagacja non-401 RuntimeException, re-import (update vs create)
|
||||
- PHPUnit + dg/bypass-finals zainstalowane i skonfigurowane (composer.phar, vendor/, bootstrap.php)
|
||||
- Odkryte i naprawione 3 bugi use-statement w kodzie produkcyjnym
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
| File | Change | Purpose |
|
||||
|------|--------|---------|
|
||||
| `tests/Unit/AllegroTokenManagerTest.php` | Created | 7 testów logiki OAuth token refresh |
|
||||
| `tests/Unit/AllegroOrderImportServiceTest.php` | Created | 5 testów importu zamówień Allegro |
|
||||
| `tests/bootstrap.php` | Modified | Dodano DG\BypassFinals::enable() |
|
||||
| `src/Modules/Settings/AllegroTokenManager.php` | Modified | Fix: use App\Core\Exceptions\AllegroOAuthException |
|
||||
| `src/Modules/Settings/AllegroIntegrationRepository.php` | Modified | Fix: use App\Core\Exceptions\IntegrationConfigException |
|
||||
| `src/Modules/Settings/AllegroOrderImportService.php` | Modified | Fix: dodano use RuntimeException |
|
||||
| `composer.json` | Modified | Dodano dg/bypass-finals do require-dev |
|
||||
| `composer.lock` | Created | Lock file z zależnościami |
|
||||
| `vendor/` | Created | Zależności Composera |
|
||||
|
||||
## Decisions Made
|
||||
|
||||
| Decision | Rationale | Impact |
|
||||
|----------|-----------|--------|
|
||||
| dg/bypass-finals zamiast usuwania final | Wszystkie klasy produkcyjne są final — usunięcie złamałoby konwencję projektu | Wymaga enable() w bootstrap.php, ale nie zmienia kodu produkcyjnego |
|
||||
| Naprawienie bugów use-statement | Testy ujawniły 3 złamane use-statements które uniemożliwiały prawidłowe działanie catch/throw | AllegroOrderImportService: 401 retry nigdy nie działał bez use RuntimeException |
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Summary
|
||||
|
||||
| Type | Count | Impact |
|
||||
|------|-------|--------|
|
||||
| Auto-fixed | 3 | Krytyczne — naprawione bugi use-statement |
|
||||
| Scope additions | 1 | composer install + bypass-finals (konieczne do uruchomienia testów) |
|
||||
| Deferred | 0 | — |
|
||||
|
||||
**Total impact:** Niezbędne poprawki odkryte przez testy. Bez nich catch(RuntimeException) w AllegroOrderImportService nigdy nie łapał 401.
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. Broken use-statement: AllegroTokenManager**
|
||||
- **Found during:** Task 1
|
||||
- **Issue:** `use AppCorexceptionsAllegroOAuthException` zamiast `use App\Core\Exceptions\AllegroOAuthException` (brak backslashy)
|
||||
- **Fix:** Poprawiony use-statement
|
||||
- **Files:** src/Modules/Settings/AllegroTokenManager.php
|
||||
- **Verification:** Test `testResolveTokenThrowsWhenNoOAuthConfig` przechodzi
|
||||
|
||||
**2. Broken use-statement: AllegroIntegrationRepository**
|
||||
- **Found during:** Task 1
|
||||
- **Issue:** `use AppCorexceptionsIntegrationConfigException` — brak backslashy
|
||||
- **Fix:** Poprawiony use-statement
|
||||
- **Files:** src/Modules/Settings/AllegroIntegrationRepository.php
|
||||
- **Verification:** Klasa ładuje się poprawnie przez autoloader
|
||||
|
||||
**3. Missing use RuntimeException: AllegroOrderImportService**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** catch(RuntimeException) w importSingleOrder() nigdy nie łapał wyjątku — brak `use RuntimeException`, więc PHP szukał `App\Modules\Settings\RuntimeException`
|
||||
- **Fix:** Dodano `use RuntimeException;`
|
||||
- **Files:** src/Modules/Settings/AllegroOrderImportService.php
|
||||
- **Verification:** Test `testImportSingleOrderRetryOn401` przechodzi
|
||||
|
||||
## Skill Audit
|
||||
|
||||
| Oczekiwany | Wywołany | Uwagi |
|
||||
|------------|---------|-------|
|
||||
| sonar-scanner | ○ | Pominięto — brak instalacji w PATH |
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
| Issue | Resolution |
|
||||
|-------|------------|
|
||||
| Brak vendor/ (composer nie był uruchomiony) | Pobrano composer.phar, uruchomiono `composer install --ignore-platform-reqs` |
|
||||
| PHP 8.2 vs wymagane ^8.4 w composer.json | Użyto `--ignore-platform-reqs` — PHPUnit 11.5 działa na 8.2 |
|
||||
| Final classes nie mogą być mockowane | Zainstalowano dg/bypass-finals, dodano enable() w bootstrap |
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
**Ready:**
|
||||
- PHPUnit w pełni skonfigurowany — następne testy można dodawać bezproblemowo
|
||||
- Wzorzec testowy ustalony: createMock + bypass-finals
|
||||
- 12 testów jako baseline regression
|
||||
|
||||
**Concerns:**
|
||||
- PHP 8.2 vs ^8.4 requirement — testy działają ale runtime wymaga 8.4
|
||||
- sonar-scanner nadal nie uruchamiany (brak w PATH)
|
||||
|
||||
**Blockers:**
|
||||
- Brak
|
||||
|
||||
---
|
||||
*Phase: 07-pre-expansion-fixes, Plan: 04*
|
||||
*Completed: 2026-03-15*
|
||||
145
.paul/phases/07-pre-expansion-fixes/07-05-SUMMARY.md
Normal file
145
.paul/phases/07-pre-expansion-fixes/07-05-SUMMARY.md
Normal file
@@ -0,0 +1,145 @@
|
||||
---
|
||||
phase: 07-pre-expansion-fixes
|
||||
plan: 05
|
||||
subsystem: shipments
|
||||
tags: [inpost, shipx-api, shipment-provider, ftp-deploy]
|
||||
|
||||
requires:
|
||||
- phase: 01-allegro-token-manager
|
||||
provides: ShipmentProviderInterface pattern from AllegroShipmentService
|
||||
|
||||
provides:
|
||||
- InpostShipmentService implementing ShipmentProviderInterface (native ShipX API)
|
||||
- Workaround remap inpost→allegro_wza removed from ShipmentController
|
||||
- vendor/ excluded from ftp-kr auto-upload (prevents dev deps on server)
|
||||
- 2 broken use-statement fixes in ShipmentController and AllegroShipmentService
|
||||
|
||||
affects: [future-carriers, inpost-configuration, ci-cd]
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns: [ShipX API integration via cURL, ShipmentProviderInterface for new carriers]
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- src/Modules/Shipments/InpostShipmentService.php
|
||||
modified:
|
||||
- src/Modules/Shipments/ShipmentController.php
|
||||
- src/Modules/Shipments/AllegroShipmentService.php
|
||||
- routes/web.php
|
||||
- .vscode/ftp-kr.json
|
||||
|
||||
key-decisions:
|
||||
- "ShipX API (natywne InPost) zamiast Allegro WZA — pełna niezależność od Allegro"
|
||||
- "vendor/ w ftp-kr ignore — zapobiega auto-upload dev deps na serwer"
|
||||
|
||||
patterns-established:
|
||||
- "Nowy carrier = nowy XxxShipmentService implements ShipmentProviderInterface + rejestracja w web.php"
|
||||
- "vendor/ deploy: ręcznie przez skrypt FTP po composer install --no-dev"
|
||||
|
||||
duration: ~20min
|
||||
completed: 2026-03-15T13:00:00Z
|
||||
---
|
||||
|
||||
# Phase 7 Plan 05: InPost ShipmentProviderInterface Summary
|
||||
|
||||
**InpostShipmentService z natywnym ShipX API zastąpił workaround remap inpost→allegro_wza. InPost działa niezależnie od Allegro.**
|
||||
|
||||
## Performance
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Duration | ~20min |
|
||||
| Completed | 2026-03-15 |
|
||||
| Tasks | 3 completed (2 auto + 1 checkpoint) |
|
||||
| Files created | 1 |
|
||||
| Files modified | 4 |
|
||||
|
||||
## Acceptance Criteria Results
|
||||
|
||||
| Criterion | Status | Notes |
|
||||
|-----------|--------|-------|
|
||||
| AC-1: InpostShipmentService implementuje ShipmentProviderInterface | Pass | php -l clean, implements ShipmentProviderInterface, 5 metod interfejsu |
|
||||
| AC-2: InPost shipments przez InPost API, nie Allegro WZA | Pass | Workaround usunięty, InpostShipmentService zarejestrowany pod kluczem 'inpost' |
|
||||
| AC-3: Brak regresji Allegro WZA | Pass | Human-verify approved — formularz ładuje się bez błędów, Allegro WZA nadal dostępne |
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- InpostShipmentService z pełną implementacją ShipX API: createShipment, checkCreationStatus, downloadLabel, getDeliveryServices
|
||||
- Workaround `if ($providerCode === 'inpost') { $providerCode = 'allegro_wza'; }` usunięty z ShipmentController
|
||||
- InpostShipmentService zarejestrowany w ShipmentProviderRegistry (routes/web.php)
|
||||
- vendor/ dodany do ftp-kr ignore — rozwiązanie problemu auto-upload dev dependencies na serwer
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
| File | Change | Purpose |
|
||||
|------|--------|---------|
|
||||
| `src/Modules/Shipments/InpostShipmentService.php` | Created | Natywna implementacja ShipX API — create, status, label |
|
||||
| `src/Modules/Shipments/ShipmentController.php` | Modified | Usunięty remap inpost→allegro_wza; fix use ShipmentException |
|
||||
| `src/Modules/Shipments/AllegroShipmentService.php` | Modified | Fix broken use-statements (IntegrationConfigException, ShipmentException) |
|
||||
| `routes/web.php` | Modified | Dodano use InpostShipmentService, wiring w ShipmentProviderRegistry |
|
||||
| `.vscode/ftp-kr.json` | Modified | Dodano vendor/, tests/, phpunit.xml, composer.* do ignore |
|
||||
|
||||
## Decisions Made
|
||||
|
||||
| Decision | Rationale | Impact |
|
||||
|----------|-----------|--------|
|
||||
| ShipX API (natywne InPost) | InpostIntegrationRepository ma pola ShipX (organization_id, locker_size, dispatch_method) — jest pod ShipX, nie Allegro WZA | InPost działa bez Allegro; InPost-only użytkownicy odblokwani |
|
||||
| vendor/ w ftp-kr ignore | Auto-upload wrzucał dev deps (phpunit, deep-copy) na serwer powodując Fatal Error | Deploy vendor/ ręcznie; dev deps nigdy nie trafią na serwer |
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Summary
|
||||
|
||||
| Type | Count | Impact |
|
||||
|------|-------|--------|
|
||||
| Auto-fixed | 2 | Broken use-statements w ShipmentController i AllegroShipmentService |
|
||||
| Scope additions | 1 | ftp-kr.json ignore (konieczne — auto-upload powodował crash na serwerze) |
|
||||
| Deferred | 0 | — |
|
||||
|
||||
**Total impact:** Niezbędne poprawki. Bez fix use-statements ShipmentException nigdy nie byłby łapany prawidłowo.
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. Broken use-statement: ShipmentController**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** `use AppCorexceptionsShipmentException` — brak backslashy
|
||||
- **Fix:** `use App\Core\Exceptions\ShipmentException`
|
||||
- **Files:** src/Modules/Shipments/ShipmentController.php
|
||||
|
||||
**2. Broken use-statements: AllegroShipmentService**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** `use AppCoreExceptionsIntegrationConfigException` i `use AppCoreExceptionsShipmentException`
|
||||
- **Fix:** Poprawione backslashe w obu use-statements
|
||||
- **Files:** src/Modules/Shipments/AllegroShipmentService.php
|
||||
|
||||
## Skill Audit
|
||||
|
||||
| Oczekiwany | Wywołany | Uwagi |
|
||||
|------------|---------|-------|
|
||||
| sonar-scanner | ○ | Zainstalowany (v4.3.5) ale nie uruchomiony w tym planie |
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
| Issue | Resolution |
|
||||
|-------|------------|
|
||||
| Auto-upload vendor/ z dev deps → Fatal Error na serwerze | Dodano vendor/ do ftp-kr ignore; deploy vendor/ ręcznie przez FTP skrypt |
|
||||
| Wiring nie w Application.php (jak zakładał plan) ale w routes/web.php | Znalezione przez grep; dodano wiring w tym samym pliku co inne providery |
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
**Ready:**
|
||||
- Wzorzec ShipmentProviderInterface sprawdzony na 3 providerach (Allegro WZA, Apaczka, InPost)
|
||||
- Dodanie nowego carrieru: 1 klasa + 1 linia w web.php
|
||||
- sonar-scanner zainstalowany (v4.3.5), gotowy do uruchomienia
|
||||
|
||||
**Concerns:**
|
||||
- InPost ShipX wymaga testów z prawdziwym tokenem sandbox — nie testowano API calls
|
||||
- 5+ broken use-statements naprawionych w fazach 07-04 i 07-05 — mogą być więcej w innych plikach
|
||||
|
||||
**Blockers:**
|
||||
- Brak
|
||||
|
||||
---
|
||||
*Phase: 07-pre-expansion-fixes, Plan: 05*
|
||||
*Completed: 2026-03-15*
|
||||
Reference in New Issue
Block a user