product variants table split off from category variants table, variant values table updated to reflect
This commit is contained in:
@@ -37,6 +37,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeProducts.ProductCategoryVariants',
|
||||
'plugin.CakeProducts.ProductVariants',
|
||||
'plugin.CakeProducts.ProductCategories',
|
||||
'plugin.CakeProducts.Products',
|
||||
'plugin.CakeProducts.ProductSkus',
|
||||
@@ -51,6 +52,8 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->disableErrorHandlerMiddleware();
|
||||
|
||||
$config = $this->getTableLocator()->exists('ProductCategoryVariants') ? [] : ['className' => ProductCategoryVariantsTable::class];
|
||||
$this->ProductCategoryVariants = $this->getTableLocator()->get('ProductCategoryVariants', $config);
|
||||
|
||||
|
||||
@@ -42,6 +42,10 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
'plugin.CakeProducts.ProductSkus',
|
||||
'plugin.CakeProducts.Products',
|
||||
'plugin.CakeProducts.ProductAttributes',
|
||||
'plugin.CakeProducts.ProductVariants',
|
||||
'plugin.CakeProducts.ProductCategoryVariants',
|
||||
'plugin.CakeProducts.ProductCategoryVariantOptions',
|
||||
'plugin.CakeProducts.ProductSkuVariantValues',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -173,15 +177,14 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
];
|
||||
$data = [
|
||||
0 => [
|
||||
'add' => '1',
|
||||
'sku' => 'cfc98a9a-29b2-44c8-b587-8156a',
|
||||
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156a',
|
||||
'price' => 1.5,
|
||||
'cost' => 1.5,
|
||||
'product_sku_variant_values' => [
|
||||
0 => [
|
||||
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
|
||||
'product_category_variant_option_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d26',
|
||||
'product_variant_id' => '2e6e4031-c430-4d07-b8d6-a4e759b72568',
|
||||
'product_category_variant_option_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d23',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
108
tests/TestCase/Model/Table/ProductVariantsTableTest.php
Normal file
108
tests/TestCase/Model/Table/ProductVariantsTableTest.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Model\Table;
|
||||
|
||||
use CakeProducts\Model\Table\ProductVariantsTable;
|
||||
use Cake\TestSuite\TestCase;
|
||||
|
||||
/**
|
||||
* CakeProducts\Model\Table\ProductVariantsTable Test Case
|
||||
*/
|
||||
class ProductVariantsTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \App\Model\Table\ProductVariantsTable
|
||||
*/
|
||||
protected $ProductVariants;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeProducts.Products',
|
||||
'plugin.CakeProducts.ProductCategoryVariants',
|
||||
'plugin.CakeProducts.ProductCategoryVariantOptions',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('ProductVariants') ? [] : ['className' => ProductVariantsTable::class];
|
||||
$this->ProductVariants = $this->getTableLocator()->get('ProductVariants', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->ProductVariants);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \App\Model\Table\ProductVariantsTable::initialize()
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'Products',
|
||||
'ProductCategoryVariants',
|
||||
'ProductCategoryVariantOptions',
|
||||
];
|
||||
$associations = $this->ProductVariants->associations();
|
||||
|
||||
$this->assertCount(count($expectedAssociations), $associations);
|
||||
foreach ($expectedAssociations as $expectedAssociation) {
|
||||
$this->assertTrue($this->ProductVariants->hasAssociation($expectedAssociation));
|
||||
}
|
||||
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [];
|
||||
$behaviors = $this->ProductVariants->behaviors();
|
||||
|
||||
$this->assertCount(count($expectedBehaviors), $behaviors);
|
||||
foreach ($expectedBehaviors as $expectedBehavior) {
|
||||
$this->assertTrue($this->ProductVariants->hasBehavior($expectedBehavior));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \App\Model\Table\ProductVariantsTable::validationDefault()
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \App\Model\Table\ProductVariantsTable::buildRules()
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
}
|
||||
@@ -64,8 +64,10 @@ class ProductsTableTest extends TestCase
|
||||
$expectedAssociations = [
|
||||
'ProductCategories',
|
||||
'ProductAttributes',
|
||||
'ProductCategoryVariants',
|
||||
'ProductVariants',
|
||||
'ProductSkus',
|
||||
'ProductPhotos',
|
||||
'PrimaryProductPhotos',
|
||||
];
|
||||
$associations = $this->Products->associations();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user