ver. 0.318: shopPRO export produktów + nowe API endpoints
- 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>
This commit is contained in:
@@ -229,7 +229,7 @@ class IntegrationsRepositoryTest extends TestCase
|
||||
'linkProduct', 'unlinkProduct',
|
||||
'apiloAuthorize', 'apiloGetAccessToken', 'apiloKeepalive', 'apiloIntegrationStatus',
|
||||
'apiloFetchList', 'apiloFetchListResult', 'apiloProductSearch', 'apiloCreateProduct',
|
||||
'getProductSku', 'shopproImportProduct',
|
||||
'getProductSku', 'shopproImportProduct', 'shopproExportProduct',
|
||||
];
|
||||
|
||||
foreach ($expectedMethods as $method) {
|
||||
|
||||
@@ -118,6 +118,7 @@ class IntegrationsControllerTest extends TestCase
|
||||
'shoppro_settings',
|
||||
'shoppro_settings_save',
|
||||
'shoppro_product_import',
|
||||
'shoppro_product_export',
|
||||
];
|
||||
|
||||
foreach ($methods as $method) {
|
||||
@@ -157,6 +158,7 @@ class IntegrationsControllerTest extends TestCase
|
||||
'apilo_product_select_delete',
|
||||
'shoppro_settings_save',
|
||||
'shoppro_product_import',
|
||||
'shoppro_product_export',
|
||||
];
|
||||
|
||||
foreach ($voidMethods as $method) {
|
||||
|
||||
@@ -186,4 +186,52 @@ class DictionariesApiControllerTest extends TestCase
|
||||
|
||||
$this->assertSame(405, http_response_code());
|
||||
}
|
||||
|
||||
public function testEnsureAttributeRejectsGetMethod(): void
|
||||
{
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
|
||||
ob_start();
|
||||
$this->controller->ensure_attribute();
|
||||
ob_get_clean();
|
||||
|
||||
$this->assertSame(405, http_response_code());
|
||||
}
|
||||
|
||||
public function testEnsureAttributeReturns400WhenNoBody(): void
|
||||
{
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
|
||||
ob_start();
|
||||
$this->controller->ensure_attribute();
|
||||
$output = ob_get_clean();
|
||||
|
||||
$this->assertSame(400, http_response_code());
|
||||
$json = json_decode($output, true);
|
||||
$this->assertSame('BAD_REQUEST', $json['code']);
|
||||
}
|
||||
|
||||
public function testEnsureAttributeValueRejectsGetMethod(): void
|
||||
{
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
|
||||
ob_start();
|
||||
$this->controller->ensure_attribute_value();
|
||||
ob_get_clean();
|
||||
|
||||
$this->assertSame(405, http_response_code());
|
||||
}
|
||||
|
||||
public function testEnsureAttributeValueReturns400WhenNoBody(): void
|
||||
{
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
|
||||
ob_start();
|
||||
$this->controller->ensure_attribute_value();
|
||||
$output = ob_get_clean();
|
||||
|
||||
$this->assertSame(400, http_response_code());
|
||||
$json = json_decode($output, true);
|
||||
$this->assertSame('BAD_REQUEST', $json['code']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,6 +351,19 @@ class ProductsApiControllerTest extends TestCase
|
||||
$this->assertSame('5901234123457', $result['ean']);
|
||||
}
|
||||
|
||||
public function testMapApiToFormDataPreservesZeroBasePriceForSaveProduct(): void
|
||||
{
|
||||
$method = new \ReflectionMethod(ProductsApiController::class, 'mapApiToFormData');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->controller, [
|
||||
'price_brutto' => 0.0,
|
||||
'languages' => ['pl' => ['name' => 'Zero']],
|
||||
]);
|
||||
|
||||
$this->assertSame('0', $result['price_brutto']);
|
||||
}
|
||||
|
||||
public function testMapApiToFormDataMapsCategories(): void
|
||||
{
|
||||
$method = new \ReflectionMethod(ProductsApiController::class, 'mapApiToFormData');
|
||||
|
||||
Reference in New Issue
Block a user