test additions variants table

This commit is contained in:
2025-06-29 22:25:38 -07:00
parent 5bb1110e7f
commit 5cba7de890
9 changed files with 414 additions and 23 deletions

View File

@@ -3,10 +3,13 @@ declare(strict_types=1);
namespace CakeProducts\Model\Table;
use Cake\Database\Type\EnumType;
use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
use CakeProducts\Model\Enum\ProductCategoryAttributeTypeId;
use CakeProducts\Model\Enum\ProductCategoryVariantTypeId;
/**
* ProductCategoryVariants Model
@@ -53,6 +56,8 @@ class ProductCategoryVariantsTable extends Table
'foreignKey' => 'product_id',
'className' => 'CakeProducts.Products',
]);
$this->getSchema()->setColumnType('variant_type_id', EnumType::from(ProductCategoryVariantTypeId::class));
}
/**
@@ -78,9 +83,9 @@ class ProductCategoryVariantsTable extends Table
->allowEmptyString('product_id');
$validator
->integer('attribute_type_id')
->requirePresence('attribute_type_id', 'create')
->notEmptyString('attribute_type_id');
->integer('variant_type_id')
->requirePresence('variant_type_id', 'create')
->notEmptyString('variant_type_id');
$validator
->boolean('enabled')