- NEW: IntegrationsRepository::shopproExportProduct() — eksport produktu do zdalnej instancji shopPRO (pola główne, tłumaczenia, custom fields, zdjęcia) - NEW: sendImageToShopproApi() — wysyłka zdjęć przez API shopPRO (base64 POST) - REFACTOR: shopproImportProduct() — wydzielono shopproDb() i missingShopproSetting(); dodano security_information, producer_id, custom fields, alt zdjęcia - NEW: AttributeRepository::ensureAttributeForApi() i ensureAttributeValueForApi() — idempotent find-or-create dla słowników - NEW: API POST dictionaries/ensure_attribute — utwórz lub znajdź atrybut - NEW: API POST dictionaries/ensure_attribute_value — utwórz lub znajdź wartość - NEW: API POST products/upload_image — przyjmuje base64, zapisuje plik i DB - NEW: IntegrationsController::shoppro_product_export() — akcja admina - NEW: przycisk "Eksportuj do shopPRO" w liście produktów - NEW: pole API key w ustawieniach integracji shopPRO Tests: 765 tests, 2153 assertions — all green Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Testy shopPRO
Instalacja PHPUnit
Opcja 1: Przez Composer (zalecane)
composer install
Opcja 2: Ręcznie (jeśli nie masz Composera)
wget https://phar.phpunit.de/phpunit-9.phar
php phpunit-9.phar --version
Uruchamianie testów
Wszystkie testy
composer test
# lub
vendor/bin/phpunit
Konkretny plik
vendor/bin/phpunit tests/Unit/Domain/Product/ProductRepositoryTest.php
Z pokryciem kodu
composer test-coverage
Anatomia testu (AAA Pattern)
public function testGetQuantityReturnsCorrectValue()
{
// Arrange - Przygotowanie
$mockDb = $this->createMock(\medoo::class);
$mockDb->method('get')->willReturn(42);
$repository = new ProductRepository($mockDb);
// Act - Wykonanie akcji
$quantity = $repository->getQuantity(123);
// Assert - Sprawdzenie wyniku
$this->assertEquals(42, $quantity);
}
Najważniejsze asercje
$this->assertEquals(expected, actual); // Równość wartości
$this->assertIsInt($value); // Typ
$this->assertNull($value); // Czy null
$this->assertTrue($condition); // Czy prawda