test fixes for product skus add

This commit is contained in:
2025-09-06 01:11:51 -07:00
parent 99f52422c1
commit f3a6384c55
8 changed files with 92 additions and 43 deletions

View File

@@ -36,7 +36,7 @@ class BaseControllerTest extends TestCase
{
parent::setUp();
$toCopy = PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS . 'images' . DS . '2c386086-f4c5-4093-bea5-ee9c29479f58.png';
$productsFolder = PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS .
$productsFolder = PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS . 'uploads' . DS .
'images' . DS . 'products' . DS . 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$newName = $productsFolder . DS . '2c386086-f4c5-4093-bea5-ee9c29479f58.png';
if (file_exists($toCopy)) {

View File

@@ -46,6 +46,8 @@ class ProductSkusControllerTest extends BaseControllerTest
parent::setUp();
// $this->enableCsrfToken();
// $this->enableSecurityToken();
$this->disableErrorHandlerMiddleware();
$config = $this->getTableLocator()->exists('ProductSkus') ? [] : ['className' => ProductSkusTable::class];
$this->ProductSkus = $this->getTableLocator()->get('ProductSkus', $config);
}
@@ -127,6 +129,7 @@ class ProductSkusControllerTest extends BaseControllerTest
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'add',
'cfc98a9a-29b2-44c8-b587-8156adc05317'
];
$this->get($url);
$this->assertResponseCode(200);
@@ -154,13 +157,16 @@ class ProductSkusControllerTest extends BaseControllerTest
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'add',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$data = [
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'sku' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'price' => 1.5,
'cost' => 1.5,
0 => [
'add' => '1',
'sku' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'price' => 1.5,
'cost' => 1.5,
],
];
$this->post($url, $data);
$this->assertResponseCode(302);
@@ -189,13 +195,15 @@ class ProductSkusControllerTest extends BaseControllerTest
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'add',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$data = [
'product_id' => '999999999', //does not exist
'sku' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'price' => 1.5,
'cost' => 1.5,
0 => [
'sku' => '',
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'price' => 1.5,
'cost' => 1.5,
],
];
$this->post($url, $data);
$this->assertResponseCode(200);