Files
shopPRO/docs/TESTING.md
Jacek Pyziak d29d396197 ver. 0.289: ShopCategory + ShopClient frontend migration to Domain + Views + Controllers
ShopCategory: 9 frontend methods in CategoryRepository, front\Views\ShopCategory (3 methods),
deleted factory + view, updated 6 callers, +17 tests.

ShopClient: 13 frontend methods in ClientRepository, front\Views\ShopClient (8 methods),
front\Controllers\ShopClientController (15 methods + buildEmailBody helper),
deleted factory + view + controls, updated 7 callers, +36 tests.

Security fix: removed hardcoded password bypass 'Legia1916'.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 10:41:40 +01:00

19 KiB

Testowanie shopPRO

Szybki start

Pelny zestaw testow

composer test

Alternatywnie (Windows):

./test.ps1
./test.bat
./test-simple.bat
./test-debug.bat

Alternatywnie (Git Bash):

./test.sh

Konkretny plik testowy

./test.ps1 tests/Unit/Domain/Product/ProductRepositoryTest.php
./test.ps1 tests/Unit/admin/Controllers/ArticlesControllerTest.php

Konkretny test (--filter)

./test.ps1 --filter testGetQuantityReturnsCorrectValue

Aktualny stan suite

Ostatnio zweryfikowano: 2026-02-17

OK (537 tests, 1648 assertions)

Aktualizacja po migracji ShopCategory + ShopClient frontend (2026-02-17, ver. 0.289):

Pelny suite: OK (537 tests, 1648 assertions)
Nowe testy: CategoryRepositoryTest (+17: getCategorySort, categoryName, categoryUrl, frontCategoryDetails, categoriesTree, blogCategoryProducts, categoryProductsCount, productsId, paginatedCategoryProducts)
Nowe testy: ClientRepositoryTest (+36: clientDetails, clientEmail, clientAddresses, addressDetails, addressDelete, addressSave, markAddressAsCurrent, authenticate 5 scenariuszy, createClient, confirmRegistration, generateNewPassword, initiatePasswordRecovery, clientOrders)
Zaktualizowane: tests/stubs/Helpers.php (stuby: lang, error, delete_session)

Aktualizacja po migracji BasketCalculator + ShopBasketController + cms\Layout removal (2026-02-17, ver. 0.288):

Pelny suite: OK (484 tests, 1528 assertions)
Nowe testy: BasketCalculatorTest (+8: summaryWp, countProducts, countProductsText — singular/plural/cast)

Aktualizacja po migracji Scontainers + ShopAttribute frontend (2026-02-17, ver. 0.287):

Pelny suite: OK (476 tests, 1512 assertions)
Nowe testy: ScontainersRepositoryTest (+2: frontScontainerDetails, frontScontainerDetailsFallback)
Nowe testy: AttributeRepositoryTest (+4: frontAttributeDetails, frontAttributeDetailsFallback, frontValueDetails, frontValueDetailsFallback)

Aktualizacja po migracji Layouts + Menu/Pages frontend (2026-02-17, ver. 0.286):

Pelny suite: OK (470 tests, 1484 assertions)
Nowe testy: LayoutsRepositoryTest (+8: categoryDefaultLayoutId, getDefaultLayout, getProductLayout fallback, getArticleLayout, getCategoryLayout fallback, getActiveLayout, getActiveLayout fallback, getActiveLayout null)
Nowe testy: PagesRepositoryTest (+8: frontPageDetails, frontPageDetailsNull, frontMainPageId, frontMainPageIdFallback, frontPageSort, frontMenuDetails, frontMenuDetailsNull, frontMenuPages)

Aktualizacja po migracji Banners frontend (2026-02-16, ver. 0.281):

Pelny suite: OK (454 tests, 1449 assertions)
Nowe testy: BannerRepositoryTest (+4: banners flat languages, banners null, mainBanner flat languages, mainBanner null)

Aktualizacja po migracji Articles frontend (2026-02-16, ver. 0.280):

Pelny suite: OK (450 tests, 1431 assertions)
Nowe testy: ArticleRepositoryTest (+13: articleDetailsFrontend, copyFromFallback, articlesIds, pageArticlesCount, pageArticlesPagination, articleNoindex, news, topArticles, newsListArticles)
Zaktualizowane: tests/bootstrap.php (stub: S::is_array_fix)

Aktualizacja po migracji Newsletter + Languages frontend (2026-02-16, ver. 0.279):

Pelny suite: OK (437 tests, 1398 assertions)
Nowe testy: NewsletterRepositoryTest (+10: unsubscribe, confirmSubscription, getHashByEmail, removeByEmail, signup, constructorOptionalDeps)
Zaktualizowane: tests/bootstrap.php (stuby: S::email_check, S::get_session, S::set_session)

Aktualizacja po migracji Settings + Languages frontend (2026-02-16, ver. 0.278):

Pelny suite: OK (427 tests, 1378 assertions)
Nowe testy: SettingsRepositoryTest (+6: allSettings, getSingleValue, bugfix param), LanguagesRepositoryTest (+7: defaultLanguage, activeLanguages, translations)
Zaktualizowane: tests/bootstrap.php (stub CacheHandler: get/set/exists)

Aktualizacja po migracji Dashboard + Update + legacy cleanup (2026-02-16, ver. 0.277):

Pelny suite: OK (414 tests, 1335 assertions)
Nowe testy: DashboardControllerTest (4), DashboardRepositoryTest (6), UpdateControllerTest (6), UpdateRepositoryTest (6)

Aktualizacja po stabilizacji ShopOrder / Integrations / Global Search (2026-02-15, ver. 0.277):

Pelny suite: OK (385 tests, 1246 assertions)
SettingsControllerTest: OK (7 tests, 10 assertions)

Aktualizacja po migracji ShopClients (2026-02-15, ver. 0.274) - testy punktowe:

OK (10 tests, 34 assertions)

Aktualizacja po migracji ShopCategory (2026-02-15, ver. 0.275) - testy punktowe:

OK (16 tests, 72 assertions)

Pelny suite po migracji ShopCategory (2026-02-15, ver. 0.275):

OK (377 tests, 1197 assertions)

Aktualizacja po migracji ShopOrder (2026-02-15, ver. 0.276) - testy punktowe:

OK (8 tests, 49 assertions)

Nowe testy dodane 2026-02-15:

  • tests/Unit/Domain/Client/ClientRepositoryTest.php
  • tests/Unit/admin/Controllers/ShopClientsControllerTest.php
  • tests/Unit/Domain/Category/CategoryRepositoryTest.php
  • tests/Unit/admin/Controllers/ShopCategoryControllerTest.php
  • tests/Unit/Domain/Order/OrderRepositoryTest.php
  • tests/Unit/admin/Controllers/ShopOrderControllerTest.php

Struktura testow

tests/
|-- bootstrap.php
|-- Unit/
|   |-- Domain/
|   |   |-- Article/ArticleRepositoryTest.php
|   |   |-- Attribute/AttributeRepositoryTest.php
|   |   |-- Banner/BannerRepositoryTest.php
|   |   |-- Basket/BasketCalculatorTest.php
|   |   |-- Cache/CacheRepositoryTest.php
|   |   |-- Coupon/CouponRepositoryTest.php
|   |   |-- Category/CategoryRepositoryTest.php
|   |   |-- Dictionaries/DictionariesRepositoryTest.php
|   |   |-- Integrations/IntegrationsRepositoryTest.php
|   |   |-- PaymentMethod/PaymentMethodRepositoryTest.php
|   |   |-- Producer/ProducerRepositoryTest.php
|   |   |-- Product/ProductRepositoryTest.php
|   |   |-- ProductSet/ProductSetRepositoryTest.php
|   |   |-- Promotion/PromotionRepositoryTest.php
|   |   |-- Settings/SettingsRepositoryTest.php
|   |   |-- ShopStatus/ShopStatusRepositoryTest.php
|   |   |-- Transport/TransportRepositoryTest.php
|   |   `-- User/UserRepositoryTest.php
|   `-- admin/
|       `-- Controllers/
|           |-- ArticlesControllerTest.php
|           |-- DictionariesControllerTest.php
|           |-- IntegrationsControllerTest.php
|           |-- ProductArchiveControllerTest.php
|           |-- SettingsControllerTest.php
|           |-- ShopAttributeControllerTest.php
|           |-- ShopCategoryControllerTest.php
|           |-- ShopCouponControllerTest.php
|           |-- ShopPaymentMethodControllerTest.php
|           |-- ShopProducerControllerTest.php
|           |-- ShopProductControllerTest.php
|           |-- ShopProductSetsControllerTest.php
|           |-- ShopPromotionControllerTest.php
|           |-- ShopStatusesControllerTest.php
|           |-- ShopTransportControllerTest.php
|           `-- UsersControllerTest.php
`-- Integration/

Tryby uruchamiania

1. TestDox (czytelna lista)

./test.bat

Uruchamia:

C:\xampp\php\php.exe phpunit.phar --testdox

2. Standard (kropki)

./test-simple.bat

Uruchamia:

C:\xampp\php\php.exe phpunit.phar

3. Debug (pelne logowanie)

./test-debug.bat

Uruchamia:

C:\xampp\php\php.exe phpunit.phar --debug

4. PowerShell (najbardziej niezawodne)

./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

.  = test przeszedl
E  = error (blad wykonania)
F  = failure (niezgodna asercja)

Przyklad sukcesu:

................................................................. 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)

$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

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):

OK (120 tests, 262 assertions)

Aktualizacja suite (finalizacja Users)

Ostatnio zweryfikowano: 2026-02-12

OK (120 tests, 262 assertions)

Aktualizacja po migracji Languages (2026-02-12):

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

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

OK (130 tests, 303 assertions)

Aktualizacja suite (release 0.256)

Ostatnio zweryfikowano: 2026-02-12

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

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

OK (150 tests, 372 assertions)

Aktualizacja suite (release 0.259)

Ostatnio zweryfikowano: 2026-02-12

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

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

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

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

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

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

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

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

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)

Aktualizacja suite (ShopStatuses refactor, ver. 0.267)

Ostatnio zweryfikowano: 2026-02-14

OK (254 tests, 736 assertions)

Nowe testy dodane 2026-02-14:

  • tests/Unit/Domain/ShopStatus/ShopStatusRepositoryTest.php (9 testow: find z ID=0, find null apilo, save update, save z ID=0, empty apilo sets null, reject negative ID, getApiloStatusId, getByIntegrationStatusId, allStatuses, whitelist sortowania)
  • tests/Unit/admin/Controllers/ShopStatusesControllerTest.php (5 testow: kontrakty metod, brak aliasow legacy, return types, DI konstruktora)

Aktualizacja suite (ShopPaymentMethod refactor, ver. 0.268)

Ostatnio zweryfikowano: 2026-02-14

OK (280 tests, 828 assertions)

Nowe testy dodane 2026-02-14:

  • tests/Unit/Domain/PaymentMethod/PaymentMethodRepositoryTest.php (14 testow: find invalid/null/normalize, save update/null/non-numeric apilo, listForAdmin whitelist, allActive, allForAdmin, findActiveById, isActive, getApiloPaymentTypeId, forTransport)
  • tests/Unit/admin/Controllers/ShopPaymentMethodControllerTest.php (5 testow: kontrakty metod, brak aliasow legacy, return types, DI konstruktora)

Aktualizacja suite (ShopTransport refactor, ver. 0.269)

Ostatnio zweryfikowano: 2026-02-14

OK (300 tests, 895 assertions)

Nowe testy dodane 2026-02-14:

  • tests/Unit/Domain/Transport/TransportRepositoryTest.php (14 testow: find invalid/null/normalize/nullables, save insert/update/failure/default reset/switch normalization, listForAdmin whitelist, allActive, getApiloCarrierAccountId, getTransportCost, allForAdmin)
  • tests/Unit/admin/Controllers/ShopTransportControllerTest.php (5 testow: kontrakty metod, brak aliasow legacy, return types, DI konstruktora z 2 repo)

Aktualizacja suite (Apilo sync hardening, ver. 0.270)

Ostatnio zweryfikowano: 2026-02-14

OK (300 tests, 895 assertions)

Zmiany testowe 2026-02-14:

  • brak nowych testow; pelna regresja po zmianach sync Apilo (TPAY -> Apilo) przeszla bez bledow

Aktualizacja suite (ShopAttribute refactor, ver. 0.271)

Ostatnio zweryfikowano: 2026-02-14

OK (312 tests, 948 assertions)

Nowe testy dodane 2026-02-14:

  • tests/Unit/Domain/Attribute/AttributeRepositoryTest.php (5 testow: domyslne dane cechy, whitelist sortowania/paginacji, zapis wartosci i domyslnej, usuwanie pustych tlumaczen, jezyk domyslny)
  • tests/Unit/admin/Controllers/ShopAttributeControllerTest.php (7 testow: kontrakty metod, brak aliasow legacy, return types, DI konstruktora, walidacja validateValuesRows)

Aktualizacja suite (ShopProductSets refactor, ver. 0.272)

Ostatnio zweryfikowano: 2026-02-15

OK (324 tests, 1000 assertions)

Nowe testy dodane 2026-02-15:

  • tests/Unit/Domain/ProductSet/ProductSetRepositoryTest.php (7 testow: find default/normalize, save insert/update, delete invalid, whitelist sortowania/paginacji, allSets)
  • tests/Unit/admin/Controllers/ShopProductSetsControllerTest.php (5 testow: kontrakty metod, aliasy legacy, return types, DI konstruktora)

Aktualizacja suite (ShopProducer refactor, ver. 0.273)

Ostatnio zweryfikowano: 2026-02-15

OK (338 tests, 1063 assertions)

Nowe testy dodane 2026-02-15:

  • tests/Unit/Domain/Producer/ProducerRepositoryTest.php (9 testow: find default/normalize, save insert/update, delete invalid/success, whitelist sortowania/paginacji, allProducers, producerProducts)
  • tests/Unit/admin/Controllers/ShopProducerControllerTest.php (5 testow: kontrakty metod, aliasy legacy, return types, DI konstruktora)

Aktualizacja suite (ShopProduct mass_edit, ver. 0.274)

Ostatnio zweryfikowano: 2026-02-15

OK (351 tests, 1091 assertions)

Nowe testy dodane 2026-02-15:

  • tests/Unit/Domain/Product/ProductRepositoryTest.php (rozszerzenie: allProductsForMassEdit, getProductsByCategory, applyDiscountPercent)
  • tests/Unit/admin/Controllers/ShopProductControllerTest.php (7 testow: kontrakty metod, return types, DI konstruktora)

Aktualizacja suite (Layouts + Menu/Pages frontend, ver. 0.286)

Ostatnio zweryfikowano: 2026-02-17

OK (470 tests, 1484 assertions)

Nowe testy dodane 2026-02-17:

  • tests/Unit/Domain/Layouts/LayoutsRepositoryTest.php (rozszerzenie: +8 testow frontend: categoryDefaultLayoutId, getDefaultLayout, getProductLayout, getArticleLayout, getCategoryLayout, getActiveLayout)
  • tests/Unit/Domain/Pages/PagesRepositoryTest.php (rozszerzenie: +8 testow frontend: frontPageDetails, frontMainPageId, frontPageSort, frontLangUrl, frontMenuDetails, frontMenuPages)

Aktualizacja suite (BasketCalculator + ShopBasketController, ver. 0.288)

Ostatnio zweryfikowano: 2026-02-17

OK (484 tests, 1528 assertions)

Nowe testy dodane 2026-02-17:

  • tests/Unit/Domain/Basket/BasketCalculatorTest.php (8 testow: summaryWp, summaryWpEmpty, countProducts, countProductsEmpty, countProductsTextSingular, countProductsTextPlural2to4, countProductsTextPlural5Plus, countProductsTextCastsToInt)

Aktualizacja suite (Scontainers + ShopAttribute frontend, ver. 0.287)

Ostatnio zweryfikowano: 2026-02-17

OK (476 tests, 1512 assertions)

Nowe testy dodane 2026-02-17:

  • tests/Unit/Domain/Scontainers/ScontainersRepositoryTest.php (rozszerzenie: +2 testow frontend: frontScontainerDetails, frontScontainerDetailsFallback)
  • tests/Unit/Domain/Attribute/AttributeRepositoryTest.php (rozszerzenie: +4 testow frontend: frontAttributeDetails, frontAttributeDetailsFallback, frontValueDetails, frontValueDetailsFallback)