category id not null but product id can be null same with sku id - product photos

This commit is contained in:
2025-11-01 23:39:15 -07:00
parent d239a98e8e
commit dc2f422247
5 changed files with 93 additions and 19 deletions

View File

@@ -166,6 +166,7 @@ class ProductPhotosControllerTest extends BaseControllerTest
if (!copy($file, $toUseFile)) {
$this->fail('Failed to copy test image');
}
$categoryId = '6d223283-361b-4f9f-a7f1-c97aa0ca4c23';
$productId = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$primaryPhotosCountBefore = $this->ProductPhotos->find()->where(['product_id' => $productId, 'primary_photo' => true])->count();
$primaryPhotoBefore = $this->ProductPhotos->find()->where(['product_id' => $productId, 'primary_photo' => true])->first();
@@ -186,6 +187,7 @@ class ProductPhotosControllerTest extends BaseControllerTest
]);
$data = [
'product_id' => $productId,
'product_category_id' => $categoryId,
'primary_photo' => 1,
'primary_category_photo' => 0,
'primary_sku_photo' => 0,
@@ -265,7 +267,7 @@ class ProductPhotosControllerTest extends BaseControllerTest
],
]);
$data = [
'product_id' => $productId,
'product_id' => '',
'product_category_id' => $categoryId,
'product_sku_id' => '',
'primary_photo' => 0,
@@ -327,7 +329,7 @@ class ProductPhotosControllerTest extends BaseControllerTest
}
$productId = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$skuId = '3a477e3e-7977-4813-81f6-f85949613979';
$categoryId = '6d223283-361b-4f9f-a7f1-c97aa0ca4c23';
$primarySkuPhotosCountBefore = $this->ProductPhotos->find()->where(['product_sku_id' => $skuId, 'primary_sku_photo' => true])->count();
$primarySkuPhotoBefore = $this->ProductPhotos->find()->where(['product_sku_id' => $skuId, 'primary_sku_photo' => true])->first();
@@ -349,6 +351,7 @@ class ProductPhotosControllerTest extends BaseControllerTest
$data = [
'product_id' => $productId,
'product_sku_id' => $skuId,
'product_category_id' => $categoryId,
'primary_photo' => 0,
'primary_category_photo' => 0,
'primary_sku_photo' => 1,
@@ -356,7 +359,7 @@ class ProductPhotosControllerTest extends BaseControllerTest
'enabled' => 1,
];
$this->post($url, $data);
// dd($this->_response);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-photos');