337 lines
8.5 KiB
Markdown
337 lines
8.5 KiB
Markdown
# Testowanie shopPRO
|
|
|
|
## Szybki start
|
|
|
|
### Pelny zestaw testow
|
|
```bash
|
|
composer test
|
|
```
|
|
|
|
Alternatywnie (Windows):
|
|
```bash
|
|
./test.ps1
|
|
./test.bat
|
|
./test-simple.bat
|
|
./test-debug.bat
|
|
```
|
|
|
|
Alternatywnie (Git Bash):
|
|
```bash
|
|
./test.sh
|
|
```
|
|
|
|
### Konkretny plik testowy
|
|
```bash
|
|
./test.ps1 tests/Unit/Domain/Product/ProductRepositoryTest.php
|
|
./test.ps1 tests/Unit/admin/Controllers/ArticlesControllerTest.php
|
|
```
|
|
|
|
### Konkretny test (`--filter`)
|
|
```bash
|
|
./test.ps1 --filter testGetQuantityReturnsCorrectValue
|
|
```
|
|
|
|
## Aktualny stan suite
|
|
|
|
Ostatnio zweryfikowano: 2026-02-13
|
|
|
|
```text
|
|
OK (235 tests, 682 assertions)
|
|
```
|
|
|
|
## Struktura testow
|
|
|
|
```text
|
|
tests/
|
|
|-- bootstrap.php
|
|
|-- Unit/
|
|
| |-- Domain/
|
|
| | |-- Article/ArticleRepositoryTest.php
|
|
| | |-- Banner/BannerRepositoryTest.php
|
|
| | |-- Cache/CacheRepositoryTest.php
|
|
| | |-- Coupon/CouponRepositoryTest.php
|
|
| | |-- Dictionaries/DictionariesRepositoryTest.php
|
|
| | |-- Product/ProductRepositoryTest.php
|
|
| | |-- Settings/SettingsRepositoryTest.php
|
|
| | |-- User/UserRepositoryTest.php
|
|
| | `-- Integrations/IntegrationsRepositoryTest.php
|
|
| `-- admin/
|
|
| `-- Controllers/
|
|
| |-- ArticlesControllerTest.php
|
|
| |-- DictionariesControllerTest.php
|
|
| |-- IntegrationsControllerTest.php
|
|
| |-- ProductArchiveControllerTest.php
|
|
| |-- SettingsControllerTest.php
|
|
| |-- ShopCouponControllerTest.php
|
|
| `-- UsersControllerTest.php
|
|
`-- Integration/
|
|
```
|
|
|
|
## Tryby uruchamiania
|
|
|
|
### 1. TestDox (czytelna lista)
|
|
```bash
|
|
./test.bat
|
|
```
|
|
Uruchamia:
|
|
```bash
|
|
C:\xampp\php\php.exe phpunit.phar --testdox
|
|
```
|
|
|
|
### 2. Standard (kropki)
|
|
```bash
|
|
./test-simple.bat
|
|
```
|
|
Uruchamia:
|
|
```bash
|
|
C:\xampp\php\php.exe phpunit.phar
|
|
```
|
|
|
|
### 3. Debug (pelne logowanie)
|
|
```bash
|
|
./test-debug.bat
|
|
```
|
|
Uruchamia:
|
|
```bash
|
|
C:\xampp\php\php.exe phpunit.phar --debug
|
|
```
|
|
|
|
### 4. PowerShell (najbardziej niezawodne)
|
|
```bash
|
|
./test.ps1
|
|
```
|
|
- najpierw probuje `php` z PATH
|
|
- jesli brak, probuje m.in. `C:\xampp\php\php.exe`
|
|
- zawsze dodaje `--do-not-cache-result`
|
|
|
|
## Interpretacja wynikow
|
|
|
|
```text
|
|
. = test przeszedl
|
|
E = error (blad wykonania)
|
|
F = failure (niezgodna asercja)
|
|
```
|
|
|
|
Przyklad sukcesu:
|
|
```text
|
|
................................................................. 65 / 82 ( 79%)
|
|
................. 82 / 82 (100%)
|
|
|
|
OK (82 tests, 181 assertions)
|
|
```
|
|
|
|
## Dodawanie nowych testow
|
|
|
|
1. Dodaj plik w odpowiednim module, np. `tests/Unit/Domain/<Module>/<Class>Test.php`.
|
|
2. Rozszerz `PHPUnit\Framework\TestCase`.
|
|
3. Nazwy metod zaczynaj od `test`.
|
|
4. Trzymaj sie wzorca AAA: Arrange, Act, Assert.
|
|
|
|
## Mockowanie (przyklad)
|
|
|
|
```php
|
|
$mockDb = $this->createMock(\medoo::class);
|
|
$mockDb->method('get')->willReturn(42);
|
|
|
|
$repo = new ProductRepository($mockDb);
|
|
$value = $repo->getQuantity(123);
|
|
|
|
$this->assertEquals(42, $value);
|
|
```
|
|
|
|
## Przydatne informacje
|
|
|
|
- Konfiguracja PHPUnit: `phpunit.xml`
|
|
- Bootstrap testow: `tests/bootstrap.php`
|
|
- Dodatkowy opis: `tests/README.md`
|
|
|
|
## Aktualizacja suite
|
|
|
|
Ostatnio zweryfikowano: 2026-02-12
|
|
|
|
```text
|
|
OK (119 tests, 256 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-12:
|
|
- `tests/Unit/Domain/User/UserRepositoryTest.php` (25 testow: CRUD, logon, 2FA verify/send, checkLogin, updateById)
|
|
- `tests/Unit/admin/Controllers/UsersControllerTest.php` (12 testow: kontrakty + normalizeUser)
|
|
|
|
Aktualizacja po migracji widokow Users (2026-02-12):
|
|
```text
|
|
OK (120 tests, 262 assertions)
|
|
```
|
|
|
|
## Aktualizacja suite (finalizacja Users)
|
|
Ostatnio zweryfikowano: 2026-02-12
|
|
|
|
```text
|
|
OK (120 tests, 262 assertions)
|
|
```
|
|
|
|
Aktualizacja po migracji Languages (2026-02-12):
|
|
```text
|
|
OK (130 tests, 301 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-12:
|
|
- `tests/Unit/Domain/Languages/LanguagesRepositoryTest.php`
|
|
- `tests/Unit/admin/Controllers/LanguagesControllerTest.php`
|
|
|
|
## Aktualizacja suite (release 0.254)
|
|
Ostatnio zweryfikowano: 2026-02-12
|
|
|
|
```text
|
|
OK (130 tests, 301 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-12:
|
|
- `tests/Unit/Domain/Languages/LanguagesRepositoryTest.php`
|
|
- `tests/Unit/admin/Controllers/LanguagesControllerTest.php`
|
|
|
|
## Aktualizacja suite (release 0.255)
|
|
Ostatnio zweryfikowano: 2026-02-12
|
|
|
|
```text
|
|
OK (130 tests, 303 assertions)
|
|
```
|
|
|
|
## Aktualizacja suite (release 0.256)
|
|
Ostatnio zweryfikowano: 2026-02-12
|
|
|
|
```text
|
|
OK (141 tests, 336 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-12:
|
|
- `tests/Unit/Domain/Layouts/LayoutsRepositoryTest.php`
|
|
- `tests/Unit/admin/Controllers/LayoutsControllerTest.php`
|
|
|
|
Zaktualizowane testy 2026-02-12:
|
|
- `tests/Unit/Domain/Languages/LanguagesRepositoryTest.php` (defaultLanguageId)
|
|
- `tests/Unit/admin/Controllers/ArticlesControllerTest.php` (konstruktor + LayoutsRepository)
|
|
|
|
## Aktualizacja suite (release 0.257)
|
|
Ostatnio zweryfikowano: 2026-02-12
|
|
|
|
```text
|
|
OK (150 tests, 372 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-12:
|
|
- `tests/Unit/Domain/Newsletter/NewsletterRepositoryTest.php`
|
|
- `tests/Unit/admin/Controllers/NewsletterControllerTest.php`
|
|
|
|
## Aktualizacja suite (release 0.258)
|
|
Ostatnio zweryfikowano: 2026-02-12
|
|
|
|
```text
|
|
OK (150 tests, 372 assertions)
|
|
```
|
|
|
|
## Aktualizacja suite (release 0.259)
|
|
Ostatnio zweryfikowano: 2026-02-12
|
|
|
|
```text
|
|
OK (158 tests, 397 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-12:
|
|
- `tests/Unit/Domain/Scontainers/ScontainersRepositoryTest.php`
|
|
- `tests/Unit/admin/Controllers/ScontainersControllerTest.php`
|
|
|
|
## Aktualizacja suite (release 0.260)
|
|
Ostatnio zweryfikowano: 2026-02-12
|
|
|
|
```text
|
|
OK (165 tests, 424 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-12:
|
|
- `tests/Unit/Domain/Article/ArticleRepositoryTest.php` (rozszerzenie o testy `restore`, `deletePermanently`, `listArchivedForAdmin`)
|
|
- `tests/Unit/admin/Controllers/ArticlesArchiveControllerTest.php`
|
|
|
|
## Aktualizacja suite (release 0.261)
|
|
Ostatnio zweryfikowano: 2026-02-13
|
|
|
|
```text
|
|
OK (176 tests, 439 assertions)
|
|
```
|
|
|
|
Nowe testy/rozszerzenia 2026-02-13:
|
|
- `tests/Unit/Domain/Article/ArticleRepositoryTest.php` (nowe przypadki dla `pagesSummaryForArticles`, `updateImageAlt`, `markFileToDelete`)
|
|
- `tests/Unit/admin/Controllers/ArticlesControllerTest.php` (nowe kontrakty dla akcji `imageAltChange`, `fileNameChange`, `imageDelete`, `fileDelete`)
|
|
|
|
## Aktualizacja suite (release 0.261)
|
|
Ostatnio zweryfikowano: 2026-02-13
|
|
|
|
```text
|
|
OK (178 tests, 443 assertions)
|
|
```
|
|
|
|
Nowe testy/rozszerzenia 2026-02-13:
|
|
- `tests/Unit/Domain/Article/ArticleRepositoryTest.php` (nowe przypadki dla `saveFilesOrder`)
|
|
|
|
## Aktualizacja suite (Pages migration)
|
|
Ostatnio zweryfikowano: 2026-02-13
|
|
|
|
```text
|
|
OK (186 tests, 478 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-13:
|
|
- `tests/Unit/Domain/Pages/PagesRepositoryTest.php`
|
|
- `tests/Unit/admin/Controllers/PagesControllerTest.php`
|
|
|
|
Zaktualizowane testy 2026-02-13:
|
|
- `tests/Unit/admin/Controllers/ArticlesControllerTest.php` (konstruktor z `Domain\\Pages\\PagesRepository`)
|
|
|
|
## Aktualizacja suite (Integrations refactor, ver. 0.263)
|
|
Ostatnio zweryfikowano: 2026-02-13
|
|
|
|
```text
|
|
OK (212 tests, 577 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-13:
|
|
- `tests/Unit/Domain/Integrations/IntegrationsRepositoryTest.php` (16 testow: getSettings, getSetting, saveSetting, linkProduct, unlinkProduct, getProductSku, apiloGetAccessToken, invalid provider, settings table mapping)
|
|
- `tests/Unit/admin/Controllers/IntegrationsControllerTest.php` (10 testow: kontrakty metod, return types, brak metod sellasist/baselinker)
|
|
|
|
Zaktualizowane pliki:
|
|
- `tests/bootstrap.php` (dodany stub `S::remove_special_chars()`)
|
|
|
|
## Aktualizacja suite (ShopPromotion refactor, ver. 0.264)
|
|
Ostatnio zweryfikowano: 2026-02-13
|
|
|
|
```text
|
|
OK (222 tests, 609 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-13:
|
|
- `tests/Unit/Domain/Promotion/PromotionRepositoryTest.php` (6 testow: find default, save insert, delete, whitelist sortowania, drzewo kategorii)
|
|
- `tests/Unit/admin/Controllers/ShopPromotionControllerTest.php` (4 testy: kontrakty metod i DI konstruktora)
|
|
|
|
## Aktualizacja suite (ShopPromotion fix + date_from, ver. 0.265)
|
|
Ostatnio zweryfikowano: 2026-02-13
|
|
|
|
```text
|
|
OK (222 tests, 614 assertions)
|
|
```
|
|
|
|
Zmiany testowe 2026-02-13:
|
|
- rozszerzenie `tests/Unit/Domain/Promotion/PromotionRepositoryTest.php` o asercje `date_from`
|
|
|
|
## Aktualizacja suite (ShopCoupon refactor, ver. 0.266)
|
|
Ostatnio zweryfikowano: 2026-02-13
|
|
|
|
```text
|
|
OK (235 tests, 682 assertions)
|
|
```
|
|
|
|
Nowe testy dodane 2026-02-13:
|
|
- `tests/Unit/Domain/Coupon/CouponRepositoryTest.php` (8 testow: find default/normalize, save insert/update, delete, whitelist sortowania, drzewo kategorii)
|
|
- `tests/Unit/admin/Controllers/ShopCouponControllerTest.php` (5 testow: kontrakty metod, aliasy legacy, DI konstruktora)
|
|
|
|
Ponowna weryfikacja po poprawkach UI (drzewko + checkboxy): 2026-02-13
|
|
- `OK (235 tests, 682 assertions)`
|