variant options wip

This commit is contained in:
2025-07-05 20:08:56 -07:00
parent c9d34f7115
commit 5adc791c20
16 changed files with 462 additions and 1 deletions

View File

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace CakeProducts\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductCategoryVariantsFixture
*/
class ProductCategoryVariantOptionsFixture extends TestFixture
{
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'variant_value' => 'Color',
'variant_label' => null,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'variant_value' => 'Size',
'variant_label' => null,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
];
parent::init();
}
}

View File

@@ -67,6 +67,7 @@ class ProductCategoriesTableTest extends TestCase
'ChildProductCategories',
// 'Products',
'ProductCategoryAttributes',
'ProductCategoryVariants',
];
$associations = $this->ProductCategories->associations();

View File

@@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
namespace CakeProducts\Test\TestCase\Model\Table;
use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable;
use Cake\TestSuite\TestCase;
/**
* App\Model\Table\ProductCategoryVariantOptionsTable Test Case
*/
class ProductCategoryVariantOptionsTableTest extends TestCase
{
/**
* Test subject
*
* @var \App\Model\Table\ProductCategoryVariantOptionsTable
*/
protected $ProductCategoryVariantOptions;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
// 'ProductCategoryVariantOptions',
// 'ProductCategoryVariants',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCategoryVariantOptions') ? [] : ['className' => ProductCategoryVariantOptionsTable::class];
$this->ProductCategoryVariantOptions = $this->getTableLocator()->get('ProductCategoryVariantOptions', $config);
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCategoryVariantOptions);
parent::tearDown();
}
/**
* TestInitialize method
*
* @return void
* @uses \App\Model\Table\ProductCategoryVariantOptionsTable::initialize()
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'ProductCategoryVariants',
];
$associations = $this->ProductCategoryVariantOptions->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCategoryVariantOptions->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [
'Timestamp',
];
$behaviors = $this->ProductCategoryVariantOptions->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCategoryVariantOptions->hasBehavior($expectedBehavior));
}
}
/**
* Test validationDefault method
*
* @return void
* @uses \App\Model\Table\ProductCategoryVariantOptionsTable::validationDefault()
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
* @uses \App\Model\Table\ProductCategoryVariantOptionsTable::buildRules()
*/
public function testBuildRules(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@@ -64,6 +64,7 @@ class ProductsTableTest extends TestCase
$expectedAssociations = [
'ProductCategories',
'ProductAttributes',
'ProductCategoryVariants',
];
$associations = $this->Products->associations();