composer update + load more dev dependencies for code quality, checkstyle fix
This commit is contained in:
+22
-2
@@ -9,11 +9,14 @@
|
||||
"dereuromark/cakephp-tools": "^3.9",
|
||||
"muffin/trash": "^4.2",
|
||||
"cakephp/cakephp": "^5.0.1",
|
||||
"bentools/cartesian-product": "dev-master"
|
||||
"bentools/cartesian-product": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^10.1",
|
||||
"cakephp/migrations": "^4.0.0"
|
||||
"cakephp/migrations": "^4.0.0",
|
||||
"cakedc/cakephp-phpstan": "^4.1",
|
||||
"dereuromark/composer-prefer-lowest": "^0.1.10",
|
||||
"fig-r/psr2r-sniffer": "^2.7"
|
||||
},
|
||||
"suggest": {
|
||||
"hi-powered-dev/cake-carts": "Allow users to add products/SKUs to a cart"
|
||||
@@ -29,5 +32,22 @@
|
||||
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/",
|
||||
"TestApp\\": "tests/test_app/src/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"check": [
|
||||
"@test",
|
||||
"@cs-check"
|
||||
],
|
||||
"test": "phpunit --colors=always",
|
||||
"cs-check": "vendor/bin/phpcs --colors",
|
||||
"cs-fix": "vendor/bin/phpcbf --colors",
|
||||
"lowest": "validate-prefer-lowest",
|
||||
"lowest-setup": "composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction && cp composer.json composer.backup && composer require --dev dereuromark/composer-prefer-lowest && mv composer.backup composer.json",
|
||||
"stan": "phpstan analyze"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\AbstractMigration;
|
||||
|
||||
class CreateProductCatalogs extends AbstractMigration
|
||||
{
|
||||
class CreateProductCatalogs extends AbstractMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateProductCatalogs extends AbstractMigration
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_catalogs', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -41,4 +40,5 @@ class CreateProductCatalogs extends AbstractMigration
|
||||
]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\AbstractMigration;
|
||||
|
||||
class CreateProductCategories extends AbstractMigration
|
||||
{
|
||||
class CreateProductCategories extends AbstractMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateProductCategories extends AbstractMigration
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_categories');
|
||||
|
||||
$table->addColumn('product_catalog_id', 'uuid', [
|
||||
@@ -75,4 +74,5 @@ class CreateProductCategories extends AbstractMigration
|
||||
]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\AbstractMigration;
|
||||
|
||||
class CreateProducts extends AbstractMigration
|
||||
{
|
||||
class CreateProducts extends AbstractMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateProducts extends AbstractMigration
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('products', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -44,4 +43,5 @@ class CreateProducts extends AbstractMigration
|
||||
// ]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\AbstractMigration;
|
||||
|
||||
class CreateProductCategoryAttributes extends AbstractMigration
|
||||
{
|
||||
class CreateProductCategoryAttributes extends AbstractMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateProductCategoryAttributes extends AbstractMigration
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_category_attributes', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -52,4 +51,5 @@ class CreateProductCategoryAttributes extends AbstractMigration
|
||||
]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\AbstractMigration;
|
||||
|
||||
class CreateProductCategoryAttributeOptions extends AbstractMigration
|
||||
{
|
||||
class CreateProductCategoryAttributeOptions extends AbstractMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateProductCategoryAttributeOptions extends AbstractMigration
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_category_attribute_options', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -45,4 +44,5 @@ class CreateProductCategoryAttributeOptions extends AbstractMigration
|
||||
]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\AbstractMigration;
|
||||
|
||||
class CreateExternalProductCatalogs extends AbstractMigration
|
||||
{
|
||||
class CreateExternalProductCatalogs extends AbstractMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateExternalProductCatalogs extends AbstractMigration
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('external_product_catalogs', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -53,4 +52,5 @@ class CreateExternalProductCatalogs extends AbstractMigration
|
||||
]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class RemoveCatalogIdFromExternalProductCatalogs extends BaseMigration
|
||||
{
|
||||
class RemoveCatalogIdFromExternalProductCatalogs extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,11 +12,11 @@ class RemoveCatalogIdFromExternalProductCatalogs extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('external_product_catalogs');
|
||||
$table->removeColumn('product_catalog_id');
|
||||
$table->removeColumn('enabled');
|
||||
$table->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class CreateExternalProductCatalogsProductCatalogs extends BaseMigration
|
||||
{
|
||||
class CreateExternalProductCatalogsProductCatalogs extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateExternalProductCatalogsProductCatalogs extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('external_product_catalogs_product_catalogs');
|
||||
$table->addColumn('external_product_catalog_id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -33,4 +32,5 @@ class CreateExternalProductCatalogsProductCatalogs extends BaseMigration
|
||||
]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class CreateProductAttributes extends BaseMigration
|
||||
{
|
||||
class CreateProductAttributes extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateProductAttributes extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_attributes', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -38,4 +37,5 @@ class CreateProductAttributes extends BaseMigration
|
||||
]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class AddSoftDeleteToAllTables extends BaseMigration
|
||||
{
|
||||
class AddSoftDeleteToAllTables extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class AddSoftDeleteToAllTables extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('products');
|
||||
$table->addColumn('deleted', 'datetime', [
|
||||
'default' => null,
|
||||
@@ -63,4 +62,5 @@ class AddSoftDeleteToAllTables extends BaseMigration
|
||||
]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class CreateProductSkus extends BaseMigration
|
||||
{
|
||||
class CreateProductSkus extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateProductSkus extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_skus', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -59,4 +58,5 @@ class CreateProductSkus extends BaseMigration
|
||||
]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\AbstractMigration;
|
||||
|
||||
class CreateProductCategoryVariants extends AbstractMigration
|
||||
{
|
||||
class CreateProductCategoryVariants extends AbstractMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateProductCategoryVariants extends AbstractMigration
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_category_variants', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -58,4 +57,5 @@ class CreateProductCategoryVariants extends AbstractMigration
|
||||
// ]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class CreateProductCategoryVariantOptions extends BaseMigration
|
||||
{
|
||||
class CreateProductCategoryVariantOptions extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class CreateProductCategoryVariantOptions extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_category_variant_options', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -53,4 +52,5 @@ class CreateProductCategoryVariantOptions extends BaseMigration
|
||||
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class AddDefaultProductTypeIdToProductCategories extends BaseMigration
|
||||
{
|
||||
class AddDefaultProductTypeIdToProductCategories extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class AddDefaultProductTypeIdToProductCategories extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_categories');
|
||||
$table->addColumn('default_product_type_id', 'integer', [
|
||||
'default' => null,
|
||||
@@ -22,4 +21,5 @@ class AddDefaultProductTypeIdToProductCategories extends BaseMigration
|
||||
]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class CreateProductPhotos extends BaseMigration
|
||||
{
|
||||
class CreateProductPhotos extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -13,8 +13,7 @@ class CreateProductPhotos extends BaseMigration
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_photos', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -84,4 +83,5 @@ class CreateProductPhotos extends BaseMigration
|
||||
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class CreateProductSkuVariantValues extends BaseMigration
|
||||
{
|
||||
class CreateProductSkuVariantValues extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -13,8 +13,7 @@ class CreateProductSkuVariantValues extends BaseMigration
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_sku_variant_values', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -34,4 +33,5 @@ class CreateProductSkuVariantValues extends BaseMigration
|
||||
]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class CreateProductVariants extends BaseMigration
|
||||
{
|
||||
class CreateProductVariants extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -13,8 +13,7 @@ class CreateProductVariants extends BaseMigration
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_variants', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -59,4 +58,5 @@ class CreateProductVariants extends BaseMigration
|
||||
// ]);
|
||||
$table->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class AddDefaultSkuToProductSkus extends BaseMigration
|
||||
{
|
||||
class AddDefaultSkuToProductSkus extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class AddDefaultSkuToProductSkus extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_skus');
|
||||
$table->addColumn('default_sku', 'boolean', [
|
||||
'default' => false,
|
||||
@@ -22,4 +21,5 @@ class AddDefaultSkuToProductSkus extends BaseMigration
|
||||
]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class AddProductCategoryIdToProductPhotos extends BaseMigration
|
||||
{
|
||||
class AddProductCategoryIdToProductPhotos extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -13,8 +13,7 @@ class AddProductCategoryIdToProductPhotos extends BaseMigration
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_photos');
|
||||
$table->addColumn('product_category_id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -26,4 +25,5 @@ class AddProductCategoryIdToProductPhotos extends BaseMigration
|
||||
]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class AddPrimarySkuPhotoToProductPhotos extends BaseMigration
|
||||
{
|
||||
class AddPrimarySkuPhotoToProductPhotos extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class AddPrimarySkuPhotoToProductPhotos extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_photos');
|
||||
$table->addColumn('primary_sku_photo', 'boolean', [
|
||||
'default' => false,
|
||||
@@ -22,4 +21,5 @@ class AddPrimarySkuPhotoToProductPhotos extends BaseMigration
|
||||
]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class AllowProductIdToBeNullInProductPhotos extends BaseMigration
|
||||
{
|
||||
class AllowProductIdToBeNullInProductPhotos extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class AllowProductIdToBeNullInProductPhotos extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
public function up(): void {
|
||||
$table = $this->table('product_photos');
|
||||
$table->changeColumn('product_id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -35,8 +34,7 @@ class AllowProductIdToBeNullInProductPhotos extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
public function down(): void {
|
||||
$table = $this->table('product_photos');
|
||||
$table->changeColumn('product_id', 'uuid', [
|
||||
'default' => null,
|
||||
@@ -50,4 +48,5 @@ class AllowProductIdToBeNullInProductPhotos extends BaseMigration
|
||||
]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class AddIsSystemToProductCategoryVariants extends BaseMigration
|
||||
{
|
||||
class AddIsSystemToProductCategoryVariants extends BaseMigration {
|
||||
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
@@ -12,8 +12,7 @@ class AddIsSystemToProductCategoryVariants extends BaseMigration
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
public function change(): void {
|
||||
$table = $this->table('product_category_variants');
|
||||
$table->addColumn('is_system_variant', 'boolean', [
|
||||
'default' => false,
|
||||
@@ -22,4 +21,5 @@ class AddIsSystemToProductCategoryVariants extends BaseMigration
|
||||
]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace Seeds;
|
||||
|
||||
use Cake\Utility\Text;
|
||||
use Migrations\BaseSeed;
|
||||
|
||||
/**
|
||||
* CreateSystemCategoryVariants seed.
|
||||
*/
|
||||
class CreateSystemCategoryVariantsSeed extends BaseSeed
|
||||
{
|
||||
class CreateSystemCategoryVariantsSeed extends BaseSeed {
|
||||
|
||||
/**
|
||||
* Run Method.
|
||||
*
|
||||
@@ -20,18 +21,17 @@ class CreateSystemCategoryVariantsSeed extends BaseSeed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
public function run(): void {
|
||||
$data = [
|
||||
[
|
||||
'id' => \Cake\Utility\Text::uuid(),
|
||||
'id' => Text::uuid(),
|
||||
'name' => 'Subscription Length',
|
||||
'product_category_id' => null,
|
||||
'enabled' => true,
|
||||
'is_system_variant' => true,
|
||||
],
|
||||
[
|
||||
'id' => \Cake\Utility\Text::uuid(),
|
||||
'id' => Text::uuid(),
|
||||
'name' => 'Subscription Length Units',
|
||||
'product_category_id' => null,
|
||||
'enabled' => true,
|
||||
@@ -52,4 +52,5 @@ class CreateSystemCategoryVariantsSeed extends BaseSeed
|
||||
$table->insert($data)->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="plugin">
|
||||
<arg value="nps"/>
|
||||
|
||||
<file>src/</file>
|
||||
<file>config/</file>
|
||||
<file>tests/</file>
|
||||
|
||||
<exclude-pattern>/tests/test_files/</exclude-pattern>
|
||||
<exclude-pattern>/tests/test_app/</exclude-pattern>
|
||||
|
||||
<rule ref="vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml"/>
|
||||
|
||||
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
|
||||
<exclude-pattern>*/config/Migrations/*</exclude-pattern>
|
||||
</rule>
|
||||
<rule ref="PhpCollective.Classes.ClassFileName.NoMatch">
|
||||
<exclude-pattern>*/config/Migrations/*</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
||||
+10
-14
@@ -13,8 +13,8 @@ use Cake\Routing\RouteBuilder;
|
||||
/**
|
||||
* Plugin for CakeProducts
|
||||
*/
|
||||
class CakeProductsPlugin extends BasePlugin
|
||||
{
|
||||
class CakeProductsPlugin extends BasePlugin {
|
||||
|
||||
/**
|
||||
* Load all the plugin configuration and bootstrap logic.
|
||||
*
|
||||
@@ -24,8 +24,7 @@ class CakeProductsPlugin extends BasePlugin
|
||||
* @param \Cake\Core\PluginApplicationInterface $app The host application
|
||||
* @return void
|
||||
*/
|
||||
public function bootstrap(PluginApplicationInterface $app): void
|
||||
{
|
||||
public function bootstrap(PluginApplicationInterface $app): void {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,8 +36,7 @@ class CakeProductsPlugin extends BasePlugin
|
||||
* @param \Cake\Routing\RouteBuilder $routes The route builder to update.
|
||||
* @return void
|
||||
*/
|
||||
public function routes(RouteBuilder $routes): void
|
||||
{
|
||||
public function routes(RouteBuilder $routes): void {
|
||||
$routes->plugin(
|
||||
'CakeProducts',
|
||||
['path' => '/cake-products'],
|
||||
@@ -46,7 +44,7 @@ class CakeProductsPlugin extends BasePlugin
|
||||
// Add custom routes here
|
||||
|
||||
$builder->fallbacks();
|
||||
}
|
||||
},
|
||||
);
|
||||
parent::routes($routes);
|
||||
}
|
||||
@@ -57,8 +55,7 @@ class CakeProductsPlugin extends BasePlugin
|
||||
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to update.
|
||||
* @return \Cake\Http\MiddlewareQueue
|
||||
*/
|
||||
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
|
||||
{
|
||||
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue {
|
||||
// Add your middlewares here
|
||||
|
||||
return $middlewareQueue;
|
||||
@@ -70,8 +67,7 @@ class CakeProductsPlugin extends BasePlugin
|
||||
* @param \Cake\Console\CommandCollection $commands The command collection to update.
|
||||
* @return \Cake\Console\CommandCollection
|
||||
*/
|
||||
public function console(CommandCollection $commands): CommandCollection
|
||||
{
|
||||
public function console(CommandCollection $commands): CommandCollection {
|
||||
// Add your commands here
|
||||
|
||||
$commands = parent::console($commands);
|
||||
@@ -82,12 +78,12 @@ class CakeProductsPlugin extends BasePlugin
|
||||
/**
|
||||
* Register application container services.
|
||||
*
|
||||
* @link https://book.cakephp.org/4/en/development/dependency-injection.html#dependency-injection
|
||||
* @param \Cake\Core\ContainerInterface $container The Container to update.
|
||||
* @return void
|
||||
* @link https://book.cakephp.org/4/en/development/dependency-injection.html#dependency-injection
|
||||
*/
|
||||
public function services(ContainerInterface $container): void
|
||||
{
|
||||
public function services(ContainerInterface $container): void {
|
||||
// Add your services here
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,5 @@ namespace CakeProducts\Controller;
|
||||
|
||||
use App\Controller\AppController as BaseController;
|
||||
|
||||
class AppController extends BaseController
|
||||
{
|
||||
class AppController extends BaseController {
|
||||
}
|
||||
|
||||
@@ -3,25 +3,21 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
|
||||
/**
|
||||
* ExternalProductCatalogs Controller
|
||||
*
|
||||
* @property \CakeProducts\Model\Table\ExternalProductCatalogsTable $ExternalProductCatalogs
|
||||
*/
|
||||
class ExternalProductCatalogsController extends AppController
|
||||
{
|
||||
class ExternalProductCatalogsController extends AppController {
|
||||
|
||||
// use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(): void
|
||||
{
|
||||
public function initialize(): void {
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
// $this->_defaultTable = 'CakeProducts.ExternalProductCatalogs';
|
||||
// $this->_tableConfigKey = 'CakeProducts.ExternalProductCatalogs.table';
|
||||
@@ -32,8 +28,7 @@ class ExternalProductCatalogsController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$query = $this->ExternalProductCatalogs->find()
|
||||
->contain(['ProductCatalogs']);
|
||||
$externalProductCatalogs = $this->paginate($query);
|
||||
@@ -45,11 +40,10 @@ class ExternalProductCatalogsController extends AppController
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id External Product Catalog id.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
public function view($id = null) {
|
||||
$externalProductCatalog = $this->ExternalProductCatalogs->get($id, contain: ['ProductCatalogs']);
|
||||
$this->set(compact('externalProductCatalog'));
|
||||
}
|
||||
@@ -59,8 +53,7 @@ class ExternalProductCatalogsController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
public function add() {
|
||||
$externalProductCatalog = $this->ExternalProductCatalogs->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
$saveOptions = [
|
||||
@@ -89,11 +82,10 @@ class ExternalProductCatalogsController extends AppController
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id External Product Catalog id.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
public function edit($id = null) {
|
||||
$externalProductCatalog = $this->ExternalProductCatalogs->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$externalProductCatalog = $this->ExternalProductCatalogs->patchEntity($externalProductCatalog, $this->request->getData());
|
||||
@@ -114,11 +106,10 @@ class ExternalProductCatalogsController extends AppController
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id External Product Catalog id.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$externalProductCatalog = $this->ExternalProductCatalogs->get($id);
|
||||
if ($this->ExternalProductCatalogs->delete($externalProductCatalog)) {
|
||||
@@ -129,4 +120,5 @@ class ExternalProductCatalogsController extends AppController
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,37 +3,32 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use Cake\Datasource\Exception\RecordNotFoundException;
|
||||
use Cake\Http\Response;
|
||||
use Cake\Log\Log;
|
||||
|
||||
/**
|
||||
* ExternalProductCatalogsProductCatalogs Controller
|
||||
*
|
||||
*/
|
||||
class ExternalProductCatalogsProductCatalogsController extends AppController
|
||||
{
|
||||
class ExternalProductCatalogsProductCatalogsController extends AppController {
|
||||
|
||||
/**
|
||||
* Add method
|
||||
*
|
||||
* @return Response|null|void Redirects on successful add, renders view otherwise.
|
||||
* @return \Cake\Http\Response|voidRedirects|null on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
public function add() {
|
||||
Log::debug('inside external product catalogs product catalogs controller add');
|
||||
$productCatalogs = $this->ExternalProductCatalogsProductCatalogs->ProductCatalogs->find('list')->toArray();
|
||||
$this->set(compact( 'productCatalogs'));
|
||||
$this->set(compact('productCatalogs'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Customers Contact id.
|
||||
* @return Response|null Redirects to index.
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
* @return Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$externalProductCatalogProductCatalog = $this->ExternalProductCatalogsProductCatalogs->get($id);
|
||||
if ($this->ExternalProductCatalogsProductCatalogs->delete($externalProductCatalogProductCatalog)) {
|
||||
@@ -48,4 +43,5 @@ class ExternalProductCatalogsProductCatalogsController extends AppController
|
||||
$externalProductCatalogProductCatalog->external_product_catalog_id,
|
||||
]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,25 +4,19 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\Exception\RecordNotFoundException;
|
||||
use Cake\Http\Response;
|
||||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use CakeProducts\Model\Table\ProductCatalogsTable;
|
||||
|
||||
/**
|
||||
* ProductCatalogs Controller
|
||||
*
|
||||
* @property ProductCatalogsTable $ProductCatalogs
|
||||
* @property \CakeProducts\Model\Table\ProductCatalogsTable $ProductCatalogs
|
||||
*/
|
||||
class ProductCatalogsController extends AppController
|
||||
{
|
||||
class ProductCatalogsController extends AppController {
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(): void
|
||||
{
|
||||
public function initialize(): void {
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
// $this->_defaultTable = 'CakeProducts.ProductCatalogs';
|
||||
// $this->_tableConfigKey = 'CakeProducts.ProductCatalogs.table';
|
||||
@@ -31,10 +25,9 @@ class ProductCatalogsController extends AppController
|
||||
/**
|
||||
* Index method
|
||||
*
|
||||
* @return Response|null|void Renders view
|
||||
* @return \Cake\Http\Response|voidRenders|null view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$query = $this->ProductCatalogs->find();
|
||||
$productCatalogs = $this->paginate($query);
|
||||
|
||||
@@ -45,11 +38,10 @@ class ProductCatalogsController extends AppController
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id Product Catalog id.
|
||||
* @return Response|null|void Renders view
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
* @return Response|null|void Renders view
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
public function view($id = null) {
|
||||
$contain = ['ProductCategories'];
|
||||
if (Configure::read('CakeProducts.internal.syncExternally', false)) {
|
||||
$contain[] = 'ExternalProductCatalogs';
|
||||
@@ -61,10 +53,9 @@ class ProductCatalogsController extends AppController
|
||||
/**
|
||||
* Add method
|
||||
*
|
||||
* @return Response|null|void Redirects on successful add, renders view otherwise.
|
||||
* @return \Cake\Http\Response|voidRedirects|null on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
public function add() {
|
||||
$productCatalogsTable = $this->ProductCatalogs;
|
||||
$productCatalog = $productCatalogsTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
@@ -87,11 +78,10 @@ class ProductCatalogsController extends AppController
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product Catalog id.
|
||||
* @return Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
* @return Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
public function edit($id = null) {
|
||||
$productCatalogsTable = $this->ProductCatalogs;
|
||||
$productCatalog = $productCatalogsTable->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
@@ -110,11 +100,10 @@ class ProductCatalogsController extends AppController
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product Catalog id.
|
||||
* @return Response|null Redirects to index.
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
* @return Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productCatalogsTable = $this->ProductCatalogs;
|
||||
$productCatalog = $productCatalogsTable->get($id);
|
||||
@@ -126,4 +115,5 @@ class ProductCatalogsController extends AppController
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use Cake\Utility\Text;
|
||||
|
||||
/**
|
||||
@@ -14,13 +11,12 @@ use Cake\Utility\Text;
|
||||
*
|
||||
* @property \CakeProducts\Model\Table\ProductCategoriesTable $ProductCategories
|
||||
*/
|
||||
class ProductCategoriesController extends AppController
|
||||
{
|
||||
class ProductCategoriesController extends AppController {
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(): void
|
||||
{
|
||||
public function initialize(): void {
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
// $this->_defaultTable = 'CakeProducts.ProductCategories';
|
||||
// $this->_tableConfigKey = 'CakeProducts.ProductCategories.table';
|
||||
@@ -31,8 +27,7 @@ class ProductCategoriesController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$query = $this->ProductCategories->find()
|
||||
->contain(['ProductCatalogs', 'ParentProductCategories']);
|
||||
$productCategories = $this->paginate($query);
|
||||
@@ -44,11 +39,10 @@ class ProductCategoriesController extends AppController
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id Product Category id.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
public function view($id = null) {
|
||||
$productCategory = $this->ProductCategories->get($id, contain: [
|
||||
'ProductCatalogs',
|
||||
'ParentProductCategories',
|
||||
@@ -67,8 +61,7 @@ class ProductCategoriesController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
public function add() {
|
||||
$productCategoriesTable = $this->ProductCategories;
|
||||
$productCategory = $productCategoriesTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
@@ -103,11 +96,10 @@ class ProductCategoriesController extends AppController
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product Category id.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
public function edit($id = null) {
|
||||
$productCategoriesTable = $this->ProductCategories;
|
||||
$productCategory = $productCategoriesTable->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
@@ -129,11 +121,10 @@ class ProductCategoriesController extends AppController
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product Category id.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productCategoriesTable = $this->ProductCategories;
|
||||
|
||||
@@ -155,8 +146,7 @@ class ProductCategoriesController extends AppController
|
||||
/**
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function select()
|
||||
{
|
||||
public function select() {
|
||||
$productCategoriesTable = $this->ProductCategories;
|
||||
$productCategoriesTable->behaviors()->get('Tree')->setConfig([
|
||||
'scope' => [
|
||||
@@ -173,4 +163,5 @@ class ProductCategoriesController extends AppController
|
||||
|
||||
$this->set(compact('productCategories'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,23 +3,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
|
||||
/**
|
||||
* ProductCategoryAttributeOptions Controller
|
||||
*
|
||||
* @property \CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable $ProductCategoryAttributeOptions
|
||||
*/
|
||||
class ProductCategoryAttributeOptionsController extends AppController
|
||||
{
|
||||
class ProductCategoryAttributeOptionsController extends AppController {
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(): void
|
||||
{
|
||||
public function initialize(): void {
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
// $this->_defaultTable = 'CakeProducts.ProductCategoryAttributeOptions';
|
||||
// $this->_tableConfigKey = 'CakeProducts.ProductCategoryAttributeOptions.table';
|
||||
@@ -30,8 +26,7 @@ class ProductCategoryAttributeOptionsController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
public function add() {
|
||||
Log::debug('inside product category attribute options controller add');
|
||||
|
||||
$productCategoryAttributeOption = $this->ProductCategoryAttributeOptions->newEmptyEntity();
|
||||
@@ -42,11 +37,10 @@ class ProductCategoryAttributeOptionsController extends AppController
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product Category Attribute Option id.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productCategoryAttributeOptionsTable = $this->ProductCategoryAttributeOptions;
|
||||
|
||||
@@ -59,4 +53,5 @@ class ProductCategoryAttributeOptionsController extends AppController
|
||||
|
||||
return $this->redirect(['controller' => 'ProductCategoryAttributes', 'action' => 'view', $productCategoryAttributeOption->product_category_attribute_id]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,27 +3,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\Exception\RecordNotFoundException;
|
||||
use Cake\Http\Response;
|
||||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use CakeProducts\Model\Enum\ProductCategoryAttributeTypeId;
|
||||
use CakeProducts\Model\Table\ProductCategoryAttributesTable;
|
||||
|
||||
/**
|
||||
* ProductCategoryAttributes Controller
|
||||
*
|
||||
* @property ProductCategoryAttributesTable $ProductCategoryAttributes
|
||||
* @property \CakeProducts\Model\Table\ProductCategoryAttributesTable $ProductCategoryAttributes
|
||||
*/
|
||||
class ProductCategoryAttributesController extends AppController
|
||||
{
|
||||
class ProductCategoryAttributesController extends AppController {
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(): void
|
||||
{
|
||||
public function initialize(): void {
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
// $this->_defaultTable = 'CakeProducts.ProductCategoryAttributes';
|
||||
// $this->_tableConfigKey = 'CakeProducts.ProductCategoryAttributes.table';
|
||||
@@ -32,10 +24,9 @@ class ProductCategoryAttributesController extends AppController
|
||||
/**
|
||||
* Index method
|
||||
*
|
||||
* @return Response|null|void Renders view
|
||||
* @return \Cake\Http\Response|voidRenders|null view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$query = $this->ProductCategoryAttributes->find()
|
||||
->contain(['ProductCategories']);
|
||||
$productCategoryAttributes = $this->paginate($query);
|
||||
@@ -47,11 +38,10 @@ class ProductCategoryAttributesController extends AppController
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id Product Category Attribute id.
|
||||
* @return Response|null|void Renders view
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
* @return Response|null|void Renders view
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
public function view($id = null) {
|
||||
$productCategoryAttribute = $this->ProductCategoryAttributes->get($id, contain: [
|
||||
'ProductCategories',
|
||||
'ProductCategoryAttributeOptions',
|
||||
@@ -63,10 +53,9 @@ class ProductCategoryAttributesController extends AppController
|
||||
/**
|
||||
* Add method
|
||||
*
|
||||
* @return Response|null|void Redirects on successful add, renders view otherwise.
|
||||
* @return \Cake\Http\Response|voidRedirects|null on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
public function add() {
|
||||
$productCategoryAttributesTable = $this->ProductCategoryAttributes;
|
||||
$productCategoryAttribute = $productCategoryAttributesTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
@@ -78,7 +67,7 @@ class ProductCategoryAttributesController extends AppController
|
||||
Log::debug(print_r($postData, true));
|
||||
$saveOptions = [
|
||||
'associated' => [
|
||||
'ProductCategoryAttributeOptions'
|
||||
'ProductCategoryAttributeOptions',
|
||||
],
|
||||
];
|
||||
$productCategoryAttribute = $productCategoryAttributesTable->patchEntity($productCategoryAttribute, $postData, $saveOptions);
|
||||
@@ -104,11 +93,10 @@ class ProductCategoryAttributesController extends AppController
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product Category Attribute id.
|
||||
* @return Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
* @return Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
public function edit($id = null) {
|
||||
$productCategoryAttributesTable = $this->ProductCategoryAttributes;
|
||||
$productCategoryAttribute = $productCategoryAttributesTable->get($id, contain: ['ProductCategoryAttributeOptions']);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
@@ -144,11 +132,10 @@ class ProductCategoryAttributesController extends AppController
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product Category Attribute id.
|
||||
* @return Response|null Redirects to index.
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
* @return Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
|
||||
$productCategoryAttributesTable = $this->ProductCategoryAttributes;
|
||||
@@ -165,10 +152,10 @@ class ProductCategoryAttributesController extends AppController
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
public function form() {
|
||||
$productCategories = $this->ProductCategoryAttributes->getAllCategoryAttributesForCategoryId($this->request->getQuery('product_category_id', '-1'));
|
||||
|
||||
$this->set(compact('productCategories'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,23 +3,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
|
||||
/**
|
||||
* ProductCategoryVariants Controller
|
||||
*
|
||||
* @property \App\Model\Table\ProductCategoryVariantsTable $ProductCategoryVariants
|
||||
*/
|
||||
class ProductCategoryVariantsController extends AppController
|
||||
{
|
||||
class ProductCategoryVariantsController extends AppController {
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(): void
|
||||
{
|
||||
public function initialize(): void {
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
// $this->_defaultTable = 'CakeProducts.ProductCategoryVariants';
|
||||
// $this->_tableConfigKey = 'CakeProducts.ProductCategoryVariants.table';
|
||||
@@ -30,8 +26,7 @@ class ProductCategoryVariantsController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$query = $this->ProductCategoryVariants->find()
|
||||
->contain(['ProductCategories', 'Products', 'ProductCategoryVariantOptions']);
|
||||
$productCategoryVariants = $this->paginate($query);
|
||||
@@ -43,11 +38,10 @@ class ProductCategoryVariantsController extends AppController
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id Product Category Variant id.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
public function view($id = null) {
|
||||
$productCategoryVariant = $this->ProductCategoryVariants->get($id, contain: [
|
||||
'ProductCategories',
|
||||
'Products',
|
||||
@@ -61,8 +55,7 @@ class ProductCategoryVariantsController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
public function add() {
|
||||
$productCategoryVariantsTable = $this->ProductCategoryVariants;
|
||||
|
||||
$productCategoryVariant = $productCategoryVariantsTable->newEmptyEntity();
|
||||
@@ -73,7 +66,7 @@ class ProductCategoryVariantsController extends AppController
|
||||
}
|
||||
$saveOptions = [
|
||||
'associated' => [
|
||||
'ProductCategoryVariantOptions'
|
||||
'ProductCategoryVariantOptions',
|
||||
],
|
||||
];
|
||||
$productCategoryVariant = $productCategoryVariantsTable->patchEntity($productCategoryVariant, $postData, $saveOptions);
|
||||
@@ -95,11 +88,10 @@ class ProductCategoryVariantsController extends AppController
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product Category Variant id.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
public function edit($id = null) {
|
||||
$productCategoryVariantsTable = $this->ProductCategoryVariants;
|
||||
$productCategoryVariant = $productCategoryVariantsTable->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
@@ -118,7 +110,7 @@ class ProductCategoryVariantsController extends AppController
|
||||
'product_category_variant_options',
|
||||
],
|
||||
'associated' => [
|
||||
'ProductCategoryVariantOptions'
|
||||
'ProductCategoryVariantOptions',
|
||||
],
|
||||
];
|
||||
$productCategoryVariant = $productCategoryVariantsTable->patchEntity($productCategoryVariant, $postData, $saveOptions);
|
||||
@@ -140,11 +132,10 @@ class ProductCategoryVariantsController extends AppController
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product Category Variant id.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productCategoryVariantsTable = $this->ProductCategoryVariants;
|
||||
|
||||
@@ -157,4 +148,5 @@ class ProductCategoryVariantsController extends AppController
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,25 +6,21 @@ namespace CakeProducts\Controller;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\Exception\RecordNotFoundException;
|
||||
use Cake\Http\Exception\ForbiddenException;
|
||||
use Cake\Http\Response;
|
||||
use Cake\Utility\Text;
|
||||
use CakeProducts\Model\Table\ProductPhotosTable;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
/**
|
||||
* ProductPhotos Controller
|
||||
*
|
||||
* @property ProductPhotosTable $ProductPhotos
|
||||
* @property \CakeProducts\Model\Table\ProductPhotosTable $ProductPhotos
|
||||
*/
|
||||
class ProductPhotosController extends AppController
|
||||
{
|
||||
class ProductPhotosController extends AppController {
|
||||
|
||||
/**
|
||||
* Index method
|
||||
*
|
||||
* @return Response|null|void Renders view
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$query = $this->ProductPhotos->find()
|
||||
->contain(['Products', 'ProductSkus', 'ProductCategories']);
|
||||
$productPhotos = $this->paginate($query);
|
||||
@@ -36,11 +32,10 @@ class ProductPhotosController extends AppController
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id Product Photo id.
|
||||
* @return Response|null|void Renders view
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
public function view($id = null) {
|
||||
$productPhoto = $this->ProductPhotos->get($id, contain: ['Products', 'ProductSkus', 'ProductCategories']);
|
||||
$this->set(compact('productPhoto'));
|
||||
}
|
||||
@@ -48,10 +43,9 @@ class ProductPhotosController extends AppController
|
||||
/**
|
||||
* Add method
|
||||
*
|
||||
* @return Response|null|void Redirects on successful add, renders view otherwise.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
public function add() {
|
||||
$productPhotosTable = $this->ProductPhotos;
|
||||
$productPhoto = $productPhotosTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
@@ -106,7 +100,7 @@ class ProductPhotosController extends AppController
|
||||
$path = $productCategoryPosted ? 'categories' : $path;
|
||||
}
|
||||
/**
|
||||
* @var UploadedFileInterface $photoObject
|
||||
* @var \Psr\Http\Message\UploadedFileInterface $photoObject
|
||||
*/
|
||||
$photoObject = $this->request->getData('photo');
|
||||
$ext = substr(strtolower($photoObject->getClientFilename()), -4);
|
||||
@@ -152,11 +146,10 @@ class ProductPhotosController extends AppController
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product Photo id.
|
||||
* @return Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
* @return Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
public function edit($id = null) {
|
||||
$productPhotosTable = $this->ProductPhotos;
|
||||
$productPhoto = $productPhotosTable->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
@@ -179,11 +172,10 @@ class ProductPhotosController extends AppController
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product Photo id.
|
||||
* @return Response|null Redirects to index.
|
||||
* @throws RecordNotFoundException When record not found.
|
||||
* @return Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productPhotosTable = $this->ProductPhotos;
|
||||
|
||||
@@ -201,14 +193,14 @@ class ProductPhotosController extends AppController
|
||||
* @param $id
|
||||
* @return Response
|
||||
*/
|
||||
public function image($id = null)
|
||||
{
|
||||
public function image($id = null) {
|
||||
$productPhoto = $this->ProductPhotos->get($id);
|
||||
|
||||
$fullPath = Configure::readOrFail('CakeProducts.photos.directory') . $productPhoto->photo_dir . DS . $productPhoto->photo_filename;
|
||||
|
||||
return $this->response->withFile($fullPath, [
|
||||
'download' => $this->request->getQuery('download', false) === '1'
|
||||
'download' => $this->request->getQuery('download', false) === '1',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,13 +12,12 @@ use function BenTools\CartesianProduct\combinations;
|
||||
*
|
||||
* @property \CakeProducts\Model\Table\ProductSkusTable $ProductSkus
|
||||
*/
|
||||
class ProductSkusController extends AppController
|
||||
{
|
||||
class ProductSkusController extends AppController {
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(): void
|
||||
{
|
||||
public function initialize(): void {
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
// $this->_defaultTable = 'CakeProducts.ProductSkus';
|
||||
// $this->_tableConfigKey = 'CakeProducts.ProductSkus.table';
|
||||
@@ -29,8 +28,7 @@ class ProductSkusController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$query = $this->ProductSkus->find()
|
||||
->contain(['Products']);
|
||||
$productSkus = $this->paginate($query);
|
||||
@@ -42,11 +40,10 @@ class ProductSkusController extends AppController
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id Product Skus id.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
public function view($id = null) {
|
||||
$productSku = $this->ProductSkus->get($id, contain: [
|
||||
'Products',
|
||||
'ProductSkuVariantValues',
|
||||
@@ -62,8 +59,7 @@ class ProductSkusController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add($productId = null)
|
||||
{
|
||||
public function add($productId = null) {
|
||||
$toGetCartesianProductsFrom = [];
|
||||
$productSkus = [];
|
||||
$product = $this->ProductSkus->Products->get($productId, contain: [
|
||||
@@ -79,7 +75,7 @@ class ProductSkusController extends AppController
|
||||
foreach ($existingProductSkusForMapping as $existingProductSkuId => $existingProductSku) {
|
||||
$existingSkusForCartesianComparison[$existingProductSkuId] = Hash::combine($existingProductSku, '{n}.product_variant_id', '{n}.product_category_variant_option_id');
|
||||
}
|
||||
$productVariants = isset($product->product_variants) ? $product->product_variants : [];
|
||||
$productVariants = $product->product_variants ?? [];
|
||||
// dd($productVariants);
|
||||
$productVariantsMapping = Hash::combine($productVariants, '{n}.product_category_variant.id', '{n}.id');
|
||||
$productCategoryVariants = Hash::extract($productVariants, '{n}.product_category_variant');
|
||||
@@ -110,7 +106,7 @@ class ProductSkusController extends AppController
|
||||
'variantNameMapping',
|
||||
'numSkusToAdd',
|
||||
'existingProductSkus',
|
||||
'existingSkusForCartesianComparison'
|
||||
'existingSkusForCartesianComparison',
|
||||
));
|
||||
|
||||
if ($this->request->is('post')) {
|
||||
@@ -164,6 +160,7 @@ class ProductSkusController extends AppController
|
||||
Log::debug(print_r('$productSkuToSave->getErrors()', true));
|
||||
Log::debug(print_r($productSkuToSave->getErrors(), true));
|
||||
dd($productSkuToSave->getErrors());
|
||||
|
||||
continue;
|
||||
}
|
||||
$successes[] = $productSkuToSave;
|
||||
@@ -178,7 +175,7 @@ class ProductSkusController extends AppController
|
||||
$this->Flash->error(__('The product SKU(s) could not be saved. Please, try again.'));
|
||||
}
|
||||
$this->set(compact(
|
||||
'productSkus'
|
||||
'productSkus',
|
||||
));
|
||||
}
|
||||
|
||||
@@ -186,11 +183,10 @@ class ProductSkusController extends AppController
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product Skus id.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
public function edit($id = null) {
|
||||
$productSku = $this->ProductSkus->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$postData = $this->request->getData();
|
||||
@@ -219,11 +215,10 @@ class ProductSkusController extends AppController
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product Skus id.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productSku = $this->ProductSkus->get($id);
|
||||
if ($this->ProductSkus->delete($productSku)) {
|
||||
@@ -238,8 +233,7 @@ class ProductSkusController extends AppController
|
||||
/**
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function select()
|
||||
{
|
||||
public function select() {
|
||||
$productSkus = $this->ProductSkus
|
||||
->find('list')
|
||||
->where(['product_id' => $this->request->getQuery('product_id', '-1')])
|
||||
@@ -248,4 +242,5 @@ class ProductSkusController extends AppController
|
||||
|
||||
$this->set(compact('productSkus'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,15 +10,14 @@ use Cake\Log\Log;
|
||||
*
|
||||
* @property \App\Model\Table\ProductVariantsTable $ProductVariants
|
||||
*/
|
||||
class ProductVariantsController extends AppController
|
||||
{
|
||||
class ProductVariantsController extends AppController {
|
||||
|
||||
/**
|
||||
* Index method
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$query = $this->ProductVariants->find()
|
||||
->contain(['ProductCategoryVariants', 'Products']);
|
||||
$productVariants = $this->paginate($query);
|
||||
@@ -30,11 +29,10 @@ class ProductVariantsController extends AppController
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id Product Variant id.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
public function view($id = null) {
|
||||
$productVariant = $this->ProductVariants->get($id, contain: ['ProductCategoryVariants', 'Products']);
|
||||
$this->set(compact('productVariant'));
|
||||
}
|
||||
@@ -44,8 +42,7 @@ class ProductVariantsController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add($productId)
|
||||
{
|
||||
public function add($productId) {
|
||||
$product = $this->ProductVariants->Products->get($productId);
|
||||
$productVariant = $this->ProductVariants->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
@@ -76,11 +73,10 @@ class ProductVariantsController extends AppController
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product Variant id.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
public function edit($id = null) {
|
||||
$productVariant = $this->ProductVariants->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$productVariant = $this->ProductVariants->patchEntity($productVariant, $this->request->getData());
|
||||
@@ -100,11 +96,10 @@ class ProductVariantsController extends AppController
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product Variant id.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productVariant = $this->ProductVariants->get($id);
|
||||
if ($this->ProductVariants->delete($productVariant)) {
|
||||
@@ -115,4 +110,5 @@ class ProductVariantsController extends AppController
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,23 +3,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
|
||||
/**
|
||||
* Products Controller
|
||||
*
|
||||
* @property \CakeProducts\Model\Table\ProductsTable $Products
|
||||
*/
|
||||
class ProductsController extends AppController
|
||||
{
|
||||
class ProductsController extends AppController {
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(): void
|
||||
{
|
||||
public function initialize(): void {
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
// $this->_defaultTable = 'CakeProducts.Products';
|
||||
// $this->_tableConfigKey = 'CakeProducts.Products.table';
|
||||
@@ -30,8 +26,7 @@ class ProductsController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$query = $this->Products->find()
|
||||
->contain(['ProductCategories']);
|
||||
$products = $this->paginate($query);
|
||||
@@ -43,11 +38,10 @@ class ProductsController extends AppController
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id Product id.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
public function view($id = null) {
|
||||
$product = $this->Products->get($id, contain: [
|
||||
'ProductCategories',
|
||||
'ProductAttributes',
|
||||
@@ -67,8 +61,7 @@ class ProductsController extends AppController
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
public function add() {
|
||||
$productsTable = $this->Products;
|
||||
$product = $productsTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
@@ -110,14 +103,14 @@ class ProductsController extends AppController
|
||||
'product_category_id',
|
||||
'product_type_id',
|
||||
'product_attributes',
|
||||
'product_category_variants'
|
||||
'product_category_variants',
|
||||
];
|
||||
$saveOptions['associated']['ProductCategoryVariants'] = [
|
||||
'fields' => [
|
||||
'name',
|
||||
'enabled',
|
||||
'product_category_variant_options',
|
||||
]
|
||||
],
|
||||
];
|
||||
$saveOptions['associated'][] = 'ProductCategoryVariants.ProductCategoryVariantOptions';
|
||||
$postData['product_category_variants'] = $productVariantsData;
|
||||
@@ -141,11 +134,10 @@ class ProductsController extends AppController
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product id.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
public function edit($id = null) {
|
||||
$productsTable = $this->Products;
|
||||
$product = $productsTable->get($id, contain: [
|
||||
'ProductAttributes',
|
||||
@@ -175,11 +167,10 @@ class ProductsController extends AppController
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product id.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
public function delete($id = null) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
|
||||
$productsTable = $this->Products;
|
||||
@@ -196,8 +187,7 @@ class ProductsController extends AppController
|
||||
/**
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function select()
|
||||
{
|
||||
public function select() {
|
||||
$productsTable = $this->Products;
|
||||
$productCategory = $productsTable->ProductCategories->find()
|
||||
->where(['id' => $this->request->getQuery('product_category_id', '-1')])
|
||||
@@ -210,4 +200,5 @@ class ProductsController extends AppController
|
||||
|
||||
$this->set(compact('products'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
namespace CakeProducts\Model\Behavior;
|
||||
|
||||
use ArrayObject;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Event\EventInterface;
|
||||
use Cake\ORM\Behavior;
|
||||
use LogicException;
|
||||
use Tools\Model\Behavior\ToggleBehavior;
|
||||
|
||||
/**
|
||||
@@ -54,4 +50,5 @@ class SecondToggleBehavior extends ToggleBehavior {
|
||||
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
namespace CakeProducts\Model\Behavior;
|
||||
|
||||
use ArrayObject;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Event\EventInterface;
|
||||
use Cake\ORM\Behavior;
|
||||
use LogicException;
|
||||
use Tools\Model\Behavior\ToggleBehavior;
|
||||
|
||||
/**
|
||||
@@ -54,4 +50,5 @@ class ThirdToggleBehavior extends ToggleBehavior {
|
||||
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
@@ -12,14 +11,14 @@ use Cake\ORM\Entity;
|
||||
* @property int $id
|
||||
* @property string $base_url
|
||||
* @property string $api_url
|
||||
* @property DateTime $created
|
||||
* @property DateTime|null $deleted
|
||||
* @property \Cake\I18n\DateTime $created
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
*
|
||||
* @property ProductCatalog[] $product_catalogs
|
||||
* @property ExternalProductCatalogsProductCatalog[] $external_product_catalogs_product_catalogs
|
||||
*/
|
||||
class ExternalProductCatalog extends Entity
|
||||
{
|
||||
class ExternalProductCatalog extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -39,4 +38,5 @@ class ExternalProductCatalog extends Entity
|
||||
// entities
|
||||
'external_product_catalogs_product_catalogs' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
@@ -12,15 +11,15 @@ use Cake\ORM\Entity;
|
||||
* @property int $id
|
||||
* @property string $external_product_catalog_id
|
||||
* @property string $product_catalog_id
|
||||
* @property DateTime $created
|
||||
* @property \Cake\I18n\DateTime $created
|
||||
* @property bool $enabled
|
||||
* @property DateTime|null $deleted
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
*
|
||||
* @property ExternalProductCatalog $external_product_catalog
|
||||
* @property ProductCatalog $product_catalog
|
||||
*/
|
||||
class ExternalProductCatalogsProductCatalog extends Entity
|
||||
{
|
||||
class ExternalProductCatalogsProductCatalog extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -41,4 +40,5 @@ class ExternalProductCatalogsProductCatalog extends Entity
|
||||
'external_product_catalog' => true,
|
||||
'product_catalog' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
use CakeProducts\Model\Enum\ProductProductTypeId;
|
||||
|
||||
/**
|
||||
* Product Entity
|
||||
@@ -13,16 +11,15 @@ use CakeProducts\Model\Enum\ProductProductTypeId;
|
||||
* @property string $id
|
||||
* @property string $name
|
||||
* @property string $product_category_id
|
||||
* @property ProductProductTypeId $product_type_id
|
||||
* @property DateTime|null $deleted
|
||||
* @property \CakeProducts\Model\Enum\ProductProductTypeId $product_type_id
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
*
|
||||
* @property ProductCategory $product_category
|
||||
* @property ProductAttribute[] $product_attributes
|
||||
* @property ProductCategoryVariant[] $product_category_variants
|
||||
*
|
||||
*/
|
||||
class Product extends Entity
|
||||
{
|
||||
class Product extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -44,4 +41,5 @@ class Product extends Entity
|
||||
'product_category_variants' => true,
|
||||
'primary_product_photo' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
@@ -14,14 +13,14 @@ use Cake\ORM\Entity;
|
||||
* @property string $product_category_attribute_id
|
||||
* @property string|null $attribute_value
|
||||
* @property string|null $product_category_attribute_option_id
|
||||
* @property DateTime|null $deleted
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
*
|
||||
* @property Product $product
|
||||
* @property ProductCategoryAttribute $product_category_attribute
|
||||
* @property ProductCategoryAttributeOption $product_category_attribute_option
|
||||
*/
|
||||
class ProductAttribute extends Entity
|
||||
{
|
||||
class ProductAttribute extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -43,4 +42,5 @@ class ProductAttribute extends Entity
|
||||
'product_category_attribute' => false,
|
||||
'product_category_attribute_option' => false,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
@@ -13,13 +12,13 @@ use Cake\ORM\Entity;
|
||||
* @property string $name
|
||||
* @property string|null $catalog_description
|
||||
* @property bool $enabled
|
||||
* @property DateTime|null $deleted
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
*
|
||||
* @property ProductCategory[] $product_categories
|
||||
* @property ExternalProductCatalog[] $external_product_catalogs
|
||||
*/
|
||||
class ProductCatalog extends Entity
|
||||
{
|
||||
class ProductCatalog extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -39,4 +38,5 @@ class ProductCatalog extends Entity
|
||||
'product_categories' => true,
|
||||
'external_product_catalogs' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
use CakeProducts\Model\Enum\ProductProductTypeId;
|
||||
|
||||
/**
|
||||
* ProductCategory Entity
|
||||
@@ -19,15 +17,15 @@ use CakeProducts\Model\Enum\ProductProductTypeId;
|
||||
* @property int $lft
|
||||
* @property int $rght
|
||||
* @property bool $enabled
|
||||
* @property DateTime|null $deleted
|
||||
* @property ProductProductTypeId|null $default_product_type_id
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
* @property \CakeProducts\Model\Enum\ProductProductTypeId|null $default_product_type_id
|
||||
*
|
||||
* @property \CakeProducts\Model\Entity\ProductCatalog $product_catalog
|
||||
* @property \CakeProducts\Model\Entity\ParentProductCategory $parent_product_category
|
||||
* @property \CakeProducts\Model\Entity\ChildProductCategory[] $child_product_categories
|
||||
*/
|
||||
class ProductCategory extends Entity
|
||||
{
|
||||
class ProductCategory extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -55,4 +53,5 @@ class ProductCategory extends Entity
|
||||
'child_product_categories' => true,
|
||||
'primary_product_photo' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
@@ -14,13 +13,13 @@ use Cake\ORM\Entity;
|
||||
* @property string|null $product_category_id
|
||||
* @property int $attribute_type_id
|
||||
* @property bool $enabled
|
||||
* @property DateTime|null $deleted
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
*
|
||||
* @property ProductCategory $product_category
|
||||
* @property ProductCategoryAttributeOption[] $product_category_attribute_options
|
||||
*/
|
||||
class ProductCategoryAttribute extends Entity
|
||||
{
|
||||
class ProductCategoryAttribute extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -41,4 +40,5 @@ class ProductCategoryAttribute extends Entity
|
||||
'product_category' => true,
|
||||
'product_category_attribute_options' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
@@ -14,12 +13,12 @@ use Cake\ORM\Entity;
|
||||
* @property string $attribute_value
|
||||
* @property string $attribute_label
|
||||
* @property bool $enabled
|
||||
* @property DateTime|null $deleted
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
*
|
||||
* @property ProductCategoryAttribute $product_category_attribute
|
||||
*/
|
||||
class ProductCategoryAttributeOption extends Entity
|
||||
{
|
||||
class ProductCategoryAttributeOption extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -39,4 +38,5 @@ class ProductCategoryAttributeOption extends Entity
|
||||
// entities
|
||||
'product_category_attribute' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
@@ -16,11 +15,11 @@ use Cake\ORM\Entity;
|
||||
* @property bool $enabled
|
||||
* @property bool $is_system_variant
|
||||
*
|
||||
* @property ProductCategory|EntityInterface $product_category
|
||||
* @property ProductCategoryVariantOption[]|EntityInterface[] $product_category_variant_options
|
||||
* @property ProductCategory|\Cake\Datasource\EntityInterface $product_category
|
||||
* @property ProductCategoryVariantOption[]|\Cake\Datasource\EntityInterface[] $product_category_variant_options
|
||||
*/
|
||||
class ProductCategoryVariant extends Entity
|
||||
{
|
||||
class ProductCategoryVariant extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -42,4 +41,5 @@ class ProductCategoryVariant extends Entity
|
||||
'product' => false,
|
||||
'product_category_variant_options' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ use Cake\ORM\Entity;
|
||||
*
|
||||
* @property \App\Model\Entity\ProductCategoryVariant $product_category_variant
|
||||
*/
|
||||
class ProductCategoryVariantOption extends Entity
|
||||
{
|
||||
class ProductCategoryVariantOption extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -38,4 +38,5 @@ class ProductCategoryVariantOption extends Entity
|
||||
// entities
|
||||
'product_category_variant' => false,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
@@ -20,16 +19,16 @@ use Cake\ORM\Entity;
|
||||
* @property bool $primary_sku_photo
|
||||
* @property int $photo_position
|
||||
* @property bool $enabled
|
||||
* @property DateTime $created
|
||||
* @property DateTime|null $modified
|
||||
* @property DateTime|null $deleted
|
||||
* @property \Cake\I18n\DateTime $created
|
||||
* @property \Cake\I18n\DateTime|null $modified
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
*
|
||||
* @property Product|null $product
|
||||
* @property ProductSku|null $product_sku
|
||||
* @property ProductCategory $product_category
|
||||
*/
|
||||
class ProductPhoto extends Entity
|
||||
{
|
||||
class ProductPhoto extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -59,4 +58,5 @@ class ProductPhoto extends Entity
|
||||
'product_sku' => false,
|
||||
'product_category' => false,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
@@ -15,16 +14,16 @@ use Cake\ORM\Entity;
|
||||
* @property string|null $barcode
|
||||
* @property string|null $price
|
||||
* @property string|null $cost
|
||||
* @property DateTime $created
|
||||
* @property DateTime|null $modified
|
||||
* @property DateTime|null $deleted
|
||||
* @property \Cake\I18n\DateTime $created
|
||||
* @property \Cake\I18n\DateTime|null $modified
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
* @property bool $default_sku
|
||||
*
|
||||
* @property Product $product
|
||||
* @property ProductSkuVariantValue[] $product_sku_variant_values
|
||||
*/
|
||||
class ProductSku extends Entity
|
||||
{
|
||||
class ProductSku extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -49,4 +48,5 @@ class ProductSku extends Entity
|
||||
'product' => false,
|
||||
'product_sku_variant_values' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ use Cake\ORM\Entity;
|
||||
* @property ProductCategoryVariant $product_category_variant
|
||||
* @property ProductCategoryVariantOption $product_category_variant_option
|
||||
*/
|
||||
class ProductSkuVariantValue extends Entity
|
||||
{
|
||||
class ProductSkuVariantValue extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -38,4 +38,5 @@ class ProductSkuVariantValue extends Entity
|
||||
'product_variant' => true,
|
||||
'product_category_variant_option' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ use Cake\ORM\Entity;
|
||||
* @property \App\Model\Entity\ProductCategoryVariant $product_category_variant
|
||||
* @property \App\Model\Entity\Product $product
|
||||
*/
|
||||
class ProductVariant extends Entity
|
||||
{
|
||||
class ProductVariant extends Entity {
|
||||
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
@@ -36,4 +36,5 @@ class ProductVariant extends Entity
|
||||
'product_category_variant' => true,
|
||||
'product' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -5,18 +5,10 @@ namespace CakeProducts\Model\Table;
|
||||
|
||||
use ArrayObject;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\Event\EventInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Behavior\TimestampBehavior;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ExternalProductCatalogsProductCatalogs Model
|
||||
@@ -24,15 +16,15 @@ use Psr\SimpleCache\CacheInterface;
|
||||
* @property ExternalProductCatalogsTable&BelongsTo $ExternalProductCatalogs
|
||||
* @property ProductCatalogsTable&BelongsTo $ProductCatalogs
|
||||
*
|
||||
* @method ExternalProductCatalogsProductCatalog newEmptyEntity()
|
||||
* @method ExternalProductCatalogsProductCatalog newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog newEntity()
|
||||
* @method array<ExternalProductCatalogsProductCatalog> newEntities(array $data, array $options = [])
|
||||
* @method ExternalProductCatalogsProductCatalog get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ExternalProductCatalogsProductCatalog findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ExternalProductCatalogsProductCatalog patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog get()
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog patchEntity()
|
||||
* @method array<ExternalProductCatalogsProductCatalog> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ExternalProductCatalogsProductCatalog|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ExternalProductCatalogsProductCatalog saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog saveOrFail()
|
||||
* @method iterable<ExternalProductCatalogsProductCatalog>|ResultSetInterface<ExternalProductCatalogsProductCatalog>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ExternalProductCatalogsProductCatalog>|ResultSetInterface<ExternalProductCatalogsProductCatalog> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ExternalProductCatalogsProductCatalog>|ResultSetInterface<ExternalProductCatalogsProductCatalog>|false deleteMany(iterable $entities, array $options = [])
|
||||
@@ -40,16 +32,15 @@ use Psr\SimpleCache\CacheInterface;
|
||||
*
|
||||
* @mixin TimestampBehavior
|
||||
*/
|
||||
class ExternalProductCatalogsProductCatalogsTable extends Table
|
||||
{
|
||||
class ExternalProductCatalogsProductCatalogsTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('external_product_catalogs_product_catalogs');
|
||||
@@ -59,7 +50,7 @@ class ExternalProductCatalogsProductCatalogsTable extends Table
|
||||
$this->addBehavior('Timestamp');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ExternalProductCatalogsProductCatalogs.entity', 'CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog')
|
||||
Configure::read('CakeProducts.ExternalProductCatalogsProductCatalogs.entity', 'CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog'),
|
||||
);
|
||||
$this->belongsTo('ExternalProductCatalogs', [
|
||||
'className' => 'CakeProducts.ExternalProductCatalogs',
|
||||
@@ -78,11 +69,10 @@ class ExternalProductCatalogsProductCatalogsTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->uuid('external_product_catalog_id')
|
||||
->notEmptyString('external_product_catalog_id');
|
||||
@@ -101,8 +91,10 @@ class ExternalProductCatalogsProductCatalogsTable extends Table
|
||||
return $validator;
|
||||
}
|
||||
|
||||
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options)
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options) {
|
||||
if (!isset($data['enabled'])) {
|
||||
$data['enabled'] = false;
|
||||
}
|
||||
@@ -112,14 +104,14 @@ class ExternalProductCatalogsProductCatalogsTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
// $rules->add($rules->existsIn(['external_product_catalog_id'], 'ExternalProductCatalogs'), ['errorField' => 'external_product_catalog_id']);
|
||||
// $rules->add($rules->existsIn(['product_catalog_id'], 'ProductCatalogs'), ['errorField' => 'product_catalog_id']);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,32 +4,24 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Behavior\TimestampBehavior;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\ExternalProductCatalog;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ExternalProductCatalogs Model
|
||||
*
|
||||
* @property ProductCatalogsTable&BelongsTo $ProductCatalogs
|
||||
*
|
||||
* @method ExternalProductCatalog newEmptyEntity()
|
||||
* @method ExternalProductCatalog newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog newEntity()
|
||||
* @method array<ExternalProductCatalog> newEntities(array $data, array $options = [])
|
||||
* @method ExternalProductCatalog get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ExternalProductCatalog findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ExternalProductCatalog patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog get()
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog patchEntity()
|
||||
* @method array<ExternalProductCatalog> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ExternalProductCatalog|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ExternalProductCatalog saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ExternalProductCatalog saveOrFail()
|
||||
* @method iterable<ExternalProductCatalog>|ResultSetInterface<ExternalProductCatalog>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ExternalProductCatalog>|ResultSetInterface<ExternalProductCatalog> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ExternalProductCatalog>|ResultSetInterface<ExternalProductCatalog>|false deleteMany(iterable $entities, array $options = [])
|
||||
@@ -37,16 +29,15 @@ use Psr\SimpleCache\CacheInterface;
|
||||
*
|
||||
* @mixin TimestampBehavior
|
||||
*/
|
||||
class ExternalProductCatalogsTable extends Table
|
||||
{
|
||||
class ExternalProductCatalogsTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('external_product_catalogs');
|
||||
@@ -56,7 +47,7 @@ class ExternalProductCatalogsTable extends Table
|
||||
$this->addBehavior('Timestamp');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ExternalProductCatalogs.entity', 'CakeProducts\Model\Entity\ExternalProductCatalog')
|
||||
Configure::read('CakeProducts.ExternalProductCatalogs.entity', 'CakeProducts\Model\Entity\ExternalProductCatalog'),
|
||||
);
|
||||
|
||||
$this->belongsToMany('ProductCatalogs', [
|
||||
@@ -77,11 +68,10 @@ class ExternalProductCatalogsTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->scalar('base_url')
|
||||
->maxLength('base_url', 255)
|
||||
@@ -107,11 +97,11 @@ class ExternalProductCatalogsTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,16 +29,15 @@ use Cake\Validation\Validator;
|
||||
* @method iterable<\App\Model\Entity\ProductAttribute>|\Cake\Datasource\ResultSetInterface<\App\Model\Entity\ProductAttribute>|false deleteMany(iterable $entities, array $options = [])
|
||||
* @method iterable<\App\Model\Entity\ProductAttribute>|\Cake\Datasource\ResultSetInterface<\App\Model\Entity\ProductAttribute> deleteManyOrFail(iterable $entities, array $options = [])
|
||||
*/
|
||||
class ProductAttributesTable extends Table
|
||||
{
|
||||
class ProductAttributesTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('product_attributes');
|
||||
@@ -46,7 +45,7 @@ class ProductAttributesTable extends Table
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ProductAttributes.entity', 'CakeProducts\Model\Entity\ProductAttribute')
|
||||
Configure::read('CakeProducts.ProductAttributes.entity', 'CakeProducts\Model\Entity\ProductAttribute'),
|
||||
);
|
||||
|
||||
$this->belongsTo('Products', [
|
||||
@@ -72,8 +71,7 @@ class ProductAttributesTable extends Table
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->uuid('product_id')
|
||||
->notEmptyString('product_id');
|
||||
@@ -105,12 +103,12 @@ class ProductAttributesTable extends Table
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->existsIn(['product_id'], 'Products'), ['errorField' => 'product_id']);
|
||||
$rules->add($rules->existsIn(['product_category_attribute_id'], 'ProductCategoryAttributes'), ['errorField' => 'product_category_attribute_id']);
|
||||
$rules->add($rules->existsIn(['product_category_attribute_option_id'], 'ProductCategoryAttributeOptions'), ['errorField' => 'product_category_attribute_option_id']);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,43 +4,36 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\ProductCatalog;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ProductCatalogs Model
|
||||
*
|
||||
* @method ProductCatalog newEmptyEntity()
|
||||
* @method ProductCatalog newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCatalog newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ProductCatalog newEntity()
|
||||
* @method array<ProductCatalog> newEntities(array $data, array $options = [])
|
||||
* @method ProductCatalog get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ProductCatalog findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ProductCatalog patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCatalog get()
|
||||
* @method \CakeProducts\Model\Entity\ProductCatalog findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ProductCatalog patchEntity()
|
||||
* @method array<ProductCatalog> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ProductCatalog|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ProductCatalog saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCatalog saveOrFail()
|
||||
* @method iterable<ProductCatalog>|ResultSetInterface<ProductCatalog>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCatalog>|ResultSetInterface<ProductCatalog> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCatalog>|ResultSetInterface<ProductCatalog>|false deleteMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCatalog>|ResultSetInterface<ProductCatalog> deleteManyOrFail(iterable $entities, array $options = [])
|
||||
*/
|
||||
class ProductCatalogsTable extends Table
|
||||
{
|
||||
class ProductCatalogsTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('product_catalogs');
|
||||
@@ -48,7 +41,7 @@ class ProductCatalogsTable extends Table
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ProductCatalogs.entity', 'CakeProducts\Model\Entity\ProductCatalog')
|
||||
Configure::read('CakeProducts.ProductCatalogs.entity', 'CakeProducts\Model\Entity\ProductCatalog'),
|
||||
);
|
||||
$this->hasMany('ProductCategories', [
|
||||
'className' => 'CakeProducts.ProductCategories',
|
||||
@@ -64,11 +57,10 @@ class ProductCatalogsTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->scalar('name')
|
||||
->maxLength('name', 255)
|
||||
@@ -97,13 +89,13 @@ class ProductCatalogsTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->isUnique(['name']), ['errorField' => 'name']);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,18 +6,10 @@ namespace CakeProducts\Model\Table;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Database\Type\EnumType;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Association\HasMany;
|
||||
use Cake\ORM\Behavior\TreeBehavior;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\ProductCategory;
|
||||
use CakeProducts\Model\Enum\ProductProductTypeId;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ProductCategories Model
|
||||
@@ -26,14 +18,14 @@ use Psr\SimpleCache\CacheInterface;
|
||||
* @property ProductCategoriesTable&BelongsTo $ParentProductCategories
|
||||
* @property ProductCategoriesTable&HasMany $ChildProductCategories
|
||||
*
|
||||
* @method ProductCategory newEmptyEntity()
|
||||
* @method ProductCategory newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategory newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategory newEntity()
|
||||
* @method array<ProductCategory> newEntities(array $data, array $options = [])
|
||||
* @method ProductCategory get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ProductCategory findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ProductCategory patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategory get()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategory findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategory patchEntity()
|
||||
* @method array<ProductCategory> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ProductCategory saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategory saveOrFail()
|
||||
* @method iterable<ProductCategory>|ResultSetInterface<ProductCategory>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategory>|ResultSetInterface<ProductCategory> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategory>|ResultSetInterface<ProductCategory>|false deleteMany(iterable $entities, array $options = [])
|
||||
@@ -41,8 +33,8 @@ use Psr\SimpleCache\CacheInterface;
|
||||
*
|
||||
* @mixin TreeBehavior
|
||||
*/
|
||||
class ProductCategoriesTable extends Table
|
||||
{
|
||||
class ProductCategoriesTable extends Table {
|
||||
|
||||
/**
|
||||
* Current scope for Tree behavior - per catalog
|
||||
*
|
||||
@@ -56,8 +48,7 @@ class ProductCategoriesTable extends Table
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
$this->treeCatalogId = 1;
|
||||
|
||||
@@ -65,7 +56,7 @@ class ProductCategoriesTable extends Table
|
||||
$this->setDisplayField('name');
|
||||
$this->setPrimaryKey('id');
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ProductCategories.entity', 'CakeProducts\Model\Entity\ProductCategory')
|
||||
Configure::read('CakeProducts.ProductCategories.entity', 'CakeProducts\Model\Entity\ProductCategory'),
|
||||
);
|
||||
$this->addBehavior('Tree', [
|
||||
'cascadeCallbacks' => true,
|
||||
@@ -131,11 +122,10 @@ class ProductCategoriesTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->uuid('product_catalog_id')
|
||||
->notEmptyString('product_catalog_id');
|
||||
@@ -173,11 +163,10 @@ class ProductCategoriesTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->isUnique(['product_catalog_id', 'name']), ['errorField' => 'product_catalog_id']);
|
||||
$rules->add($rules->existsIn(['product_catalog_id'], 'ProductCatalogs'), ['errorField' => 'product_catalog_id']);
|
||||
$rules->add($rules->existsIn(['parent_id'], 'ParentProductCategories'), ['errorField' => 'parent_id']);
|
||||
@@ -186,24 +175,22 @@ class ProductCategoriesTable extends Table
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $catalogId
|
||||
* @param string $catalogId
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setConfigureCatalogId(string $catalogId)
|
||||
{
|
||||
public function setConfigureCatalogId(string $catalogId) {
|
||||
$this->treeCatalogId = $catalogId;
|
||||
$this->behaviors()->Tree->setConfig('scope', ['product_catalog_id' => $this->treeCatalogId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EntityInterface $entity
|
||||
* @param \Cake\Datasource\EntityInterface $entity
|
||||
* @param array $options
|
||||
*
|
||||
* @return EntityInterface|false
|
||||
* @return \Cake\Datasource\EntityInterface|false
|
||||
*/
|
||||
public function save(EntityInterface $entity, array $options = []): EntityInterface|false
|
||||
{
|
||||
public function save(EntityInterface $entity, array $options = []): EntityInterface|false {
|
||||
$this->behaviors()->get('Tree')->setConfig([
|
||||
'scope' => [
|
||||
'product_catalog_id' => $entity->product_catalog_id,
|
||||
@@ -212,4 +199,5 @@ class ProductCategoriesTable extends Table
|
||||
|
||||
return parent::save($entity, $options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,46 +4,38 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\ProductCategoryAttributeOption;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ProductCategoryAttributeOptions Model
|
||||
*
|
||||
* @property ProductCategoryAttributesTable&BelongsTo $ProductCategoryAttributes
|
||||
*
|
||||
* @method ProductCategoryAttributeOption newEmptyEntity()
|
||||
* @method ProductCategoryAttributeOption newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption newEntity()
|
||||
* @method array<ProductCategoryAttributeOption> newEntities(array $data, array $options = [])
|
||||
* @method ProductCategoryAttributeOption get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ProductCategoryAttributeOption findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ProductCategoryAttributeOption patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption get()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption patchEntity()
|
||||
* @method array<ProductCategoryAttributeOption> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ProductCategoryAttributeOption|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ProductCategoryAttributeOption saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption saveOrFail()
|
||||
* @method iterable<ProductCategoryAttributeOption>|ResultSetInterface<ProductCategoryAttributeOption>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryAttributeOption>|ResultSetInterface<ProductCategoryAttributeOption> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryAttributeOption>|ResultSetInterface<ProductCategoryAttributeOption>|false deleteMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryAttributeOption>|ResultSetInterface<ProductCategoryAttributeOption> deleteManyOrFail(iterable $entities, array $options = [])
|
||||
*/
|
||||
class ProductCategoryAttributeOptionsTable extends Table
|
||||
{
|
||||
class ProductCategoryAttributeOptionsTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('product_category_attribute_options');
|
||||
@@ -51,7 +43,7 @@ class ProductCategoryAttributeOptionsTable extends Table
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ProductCategoryAttributeOptions.entity', 'CakeProducts\Model\Entity\ProductCategoryAttributeOption')
|
||||
Configure::read('CakeProducts.ProductCategoryAttributeOptions.entity', 'CakeProducts\Model\Entity\ProductCategoryAttributeOption'),
|
||||
);
|
||||
|
||||
$this->belongsTo('ProductCategoryAttributes', [
|
||||
@@ -66,11 +58,10 @@ class ProductCategoryAttributeOptionsTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->uuid('product_category_attribute_id')
|
||||
->notEmptyString('product_category_attribute_id');
|
||||
@@ -102,14 +93,14 @@ class ProductCategoryAttributeOptionsTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->existsIn(['product_category_attribute_id'], 'ProductCategoryAttributes'), ['errorField' => 'product_category_attribute_id']);
|
||||
$rules->add($rules->isUnique(['attribute_value', 'product_category_attribute_id']));
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,47 +5,40 @@ namespace CakeProducts\Model\Table;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Database\Type\EnumType;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\ProductCategoryAttribute;
|
||||
use CakeProducts\Model\Enum\ProductCategoryAttributeTypeId;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ProductCategoryAttributes Model
|
||||
*
|
||||
* @property ProductCategoriesTable&BelongsTo $ProductCategories
|
||||
*
|
||||
* @method ProductCategoryAttribute newEmptyEntity()
|
||||
* @method ProductCategoryAttribute newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttribute newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttribute newEntity()
|
||||
* @method array<ProductCategoryAttribute> newEntities(array $data, array $options = [])
|
||||
* @method ProductCategoryAttribute get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ProductCategoryAttribute findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ProductCategoryAttribute patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttribute get()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttribute findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttribute patchEntity()
|
||||
* @method array<ProductCategoryAttribute> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ProductCategoryAttribute|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ProductCategoryAttribute saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryAttribute saveOrFail()
|
||||
* @method iterable<ProductCategoryAttribute>|ResultSetInterface<ProductCategoryAttribute>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryAttribute>|ResultSetInterface<ProductCategoryAttribute> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryAttribute>|ResultSetInterface<ProductCategoryAttribute>|false deleteMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryAttribute>|ResultSetInterface<ProductCategoryAttribute> deleteManyOrFail(iterable $entities, array $options = [])
|
||||
*/
|
||||
class ProductCategoryAttributesTable extends Table
|
||||
{
|
||||
class ProductCategoryAttributesTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('product_category_attributes');
|
||||
@@ -53,7 +46,7 @@ class ProductCategoryAttributesTable extends Table
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ProductCategoryAttributes.entity', 'CakeProducts\Model\Entity\ProductCategoryAttribute')
|
||||
Configure::read('CakeProducts.ProductCategoryAttributes.entity', 'CakeProducts\Model\Entity\ProductCategoryAttribute'),
|
||||
);
|
||||
$this->belongsTo('ProductCategories', [
|
||||
'foreignKey' => 'product_category_id',
|
||||
@@ -76,11 +69,10 @@ class ProductCategoryAttributesTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->scalar('name')
|
||||
->maxLength('name', 255)
|
||||
@@ -112,11 +104,10 @@ class ProductCategoryAttributesTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->isUnique(['name', 'product_category_id'], ['allowMultipleNulls' => true]), ['errorField' => 'name']);
|
||||
$rules->add($rules->existsIn(['product_category_id'], 'ProductCategories'), ['errorField' => 'product_category_id']);
|
||||
|
||||
@@ -124,13 +115,12 @@ class ProductCategoryAttributesTable extends Table
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectQuery $query
|
||||
* @param \Cake\ORM\Query\SelectQuery $query
|
||||
* @param string $internalCategoryId
|
||||
*
|
||||
* @return array|\Cake\ORM\Query|SelectQuery
|
||||
* @return \Cake\ORM\Query|\Cake\ORM\Query\SelectQuery|array
|
||||
*/
|
||||
public function findAllCategoryAttributesForCategoryId(SelectQuery $query, string $internalCategoryId)
|
||||
{
|
||||
public function findAllCategoryAttributesForCategoryId(SelectQuery $query, string $internalCategoryId) {
|
||||
$category = $this->ProductCategories->find()->where(['internal_id' => $internalCategoryId])->firstOrFail();
|
||||
|
||||
$this->ProductCategories->behaviors()->get('Tree')->setConfig([
|
||||
@@ -143,8 +133,13 @@ class ProductCategoryAttributesTable extends Table
|
||||
->find('path', for: $category->id)
|
||||
->contain(['ProductCategoryAttributes', 'ProductCategoryAttributes.ProductCategoryAttributeOptions']);
|
||||
}
|
||||
public function getAllCategoryAttributesForCategoryId(string $internalCategoryId)
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $internalCategoryId
|
||||
* @return array|array[]|\Cake\Datasource\EntityInterface[]
|
||||
*/
|
||||
public function getAllCategoryAttributesForCategoryId(string $internalCategoryId) {
|
||||
return $this->find('allCategoryAttributesForCategoryId', $internalCategoryId)->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,33 +4,24 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use CakeProducts\Model\Entity\ProductCategoryVariantOption;
|
||||
use CakeProducts\Model\Table\ProductCategoryVariantsTable;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Behavior\TimestampBehavior;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ProductCategoryVariantOptions Model
|
||||
*
|
||||
* @property ProductCategoryVariantsTable&BelongsTo $ProductCategoryVariants
|
||||
*
|
||||
* @method ProductCategoryVariantOption newEmptyEntity()
|
||||
* @method ProductCategoryVariantOption newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariantOption newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariantOption newEntity()
|
||||
* @method array<ProductCategoryVariantOption> newEntities(array $data, array $options = [])
|
||||
* @method ProductCategoryVariantOption get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ProductCategoryVariantOption findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ProductCategoryVariantOption patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariantOption get()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariantOption findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariantOption patchEntity()
|
||||
* @method array<ProductCategoryVariantOption> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ProductCategoryVariantOption|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ProductCategoryVariantOption saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariantOption saveOrFail()
|
||||
* @method iterable<ProductCategoryVariantOption>|ResultSetInterface<ProductCategoryVariantOption>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryVariantOption>|ResultSetInterface<ProductCategoryVariantOption> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryVariantOption>|ResultSetInterface<ProductCategoryVariantOption>|false deleteMany(iterable $entities, array $options = [])
|
||||
@@ -38,16 +29,15 @@ use Psr\SimpleCache\CacheInterface;
|
||||
*
|
||||
* @mixin TimestampBehavior
|
||||
*/
|
||||
class ProductCategoryVariantOptionsTable extends Table
|
||||
{
|
||||
class ProductCategoryVariantOptionsTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('product_category_variant_options');
|
||||
@@ -55,7 +45,7 @@ class ProductCategoryVariantOptionsTable extends Table
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ProductCategoryVariantOptions.entity', 'CakeProducts\Model\Entity\ProductCategoryVariantOption')
|
||||
Configure::read('CakeProducts.ProductCategoryVariantOptions.entity', 'CakeProducts\Model\Entity\ProductCategoryVariantOption'),
|
||||
);
|
||||
$this->addBehavior('Timestamp');
|
||||
|
||||
@@ -68,11 +58,10 @@ class ProductCategoryVariantOptionsTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->uuid('product_category_variant_id')
|
||||
->notEmptyString('product_category_variant_id');
|
||||
@@ -99,14 +88,14 @@ class ProductCategoryVariantOptionsTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->existsIn(['product_category_variant_id'], 'ProductCategoryVariants'), ['errorField' => 'product_category_variant_id']);
|
||||
$rules->add($rules->isUnique(['variant_value', 'product_category_variant_id']));
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,17 +4,10 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Query;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\ProductCategoryVariant;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ProductCategoryVariants Model
|
||||
@@ -22,30 +15,29 @@ use Psr\SimpleCache\CacheInterface;
|
||||
* @property ProductCategoriesTable&BelongsTo $ProductCategories
|
||||
* @property ProductsTable&BelongsTo $Products
|
||||
*
|
||||
* @method ProductCategoryVariant newEmptyEntity()
|
||||
* @method ProductCategoryVariant newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariant newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariant newEntity()
|
||||
* @method array<ProductCategoryVariant> newEntities(array $data, array $options = [])
|
||||
* @method ProductCategoryVariant get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ProductCategoryVariant findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ProductCategoryVariant patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariant get()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariant findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariant patchEntity()
|
||||
* @method array<ProductCategoryVariant> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ProductCategoryVariant|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ProductCategoryVariant saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductCategoryVariant saveOrFail()
|
||||
* @method iterable<ProductCategoryVariant>|ResultSetInterface<ProductCategoryVariant>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryVariant>|ResultSetInterface<ProductCategoryVariant> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryVariant>|ResultSetInterface<ProductCategoryVariant>|false deleteMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductCategoryVariant>|ResultSetInterface<ProductCategoryVariant> deleteManyOrFail(iterable $entities, array $options = [])
|
||||
*/
|
||||
class ProductCategoryVariantsTable extends Table
|
||||
{
|
||||
class ProductCategoryVariantsTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('product_category_variants');
|
||||
@@ -53,7 +45,7 @@ class ProductCategoryVariantsTable extends Table
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ProductCategoryVariants.entity', 'CakeProducts\Model\Entity\ProductCategoryVariant')
|
||||
Configure::read('CakeProducts.ProductCategoryVariants.entity', 'CakeProducts\Model\Entity\ProductCategoryVariant'),
|
||||
);
|
||||
|
||||
$this->belongsTo('ProductCategories', [
|
||||
@@ -84,11 +76,10 @@ class ProductCategoryVariantsTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->scalar('name')
|
||||
->maxLength('name', 255)
|
||||
@@ -119,11 +110,10 @@ class ProductCategoryVariantsTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->isUnique(['name', 'product_category_id'], ['allowMultipleNulls' => true]), ['errorField' => 'product_category_id']);
|
||||
$rules->add($rules->isUnique(['name', 'product_id'], ['allowMultipleNulls' => true]), ['errorField' => 'product_id']);
|
||||
$rules->add($rules->existsIn(['product_category_id'], 'ProductCategories'), ['errorField' => 'product_category_id']);
|
||||
@@ -133,13 +123,12 @@ class ProductCategoryVariantsTable extends Table
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectQuery $query
|
||||
* @param \Cake\ORM\Query\SelectQuery $query
|
||||
* @param string $internalCategoryId
|
||||
*
|
||||
* @return array|Query|SelectQuery
|
||||
* @return Query|\Cake\ORM\Query\SelectQuery|array
|
||||
*/
|
||||
public function findAllCategoryVariantsForCategoryId(SelectQuery $query, string $internalCategoryId)
|
||||
{
|
||||
public function findAllCategoryVariantsForCategoryId(SelectQuery $query, string $internalCategoryId) {
|
||||
$category = $this->ProductCategories->find()->where(['internal_id' => $internalCategoryId])->firstOrFail();
|
||||
|
||||
$this->ProductCategories->behaviors()->get('Tree')->setConfig([
|
||||
@@ -157,8 +146,8 @@ class ProductCategoryVariantsTable extends Table
|
||||
* @param string $internalCategoryId
|
||||
* @return array
|
||||
*/
|
||||
public function getAllCategoryVariantsForCategoryId(string $internalCategoryId)
|
||||
{
|
||||
public function getAllCategoryVariantsForCategoryId(string $internalCategoryId) {
|
||||
return $this->find('allCategoryVariantsForCategoryId', $internalCategoryId)->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,16 +4,9 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Behavior\TimestampBehavior;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\ProductPhoto;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ProductPhotos Model
|
||||
@@ -21,15 +14,15 @@ use Psr\SimpleCache\CacheInterface;
|
||||
* @property ProductsTable&BelongsTo $Products
|
||||
* @property ProductSkusTable&BelongsTo $ProductSkus
|
||||
*
|
||||
* @method ProductPhoto newEmptyEntity()
|
||||
* @method ProductPhoto newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductPhoto newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ProductPhoto newEntity()
|
||||
* @method array<ProductPhoto> newEntities(array $data, array $options = [])
|
||||
* @method ProductPhoto get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ProductPhoto findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ProductPhoto patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductPhoto get()
|
||||
* @method \CakeProducts\Model\Entity\ProductPhoto findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ProductPhoto patchEntity()
|
||||
* @method array<ProductPhoto> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ProductPhoto|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ProductPhoto saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductPhoto saveOrFail()
|
||||
* @method iterable<ProductPhoto>|ResultSetInterface<ProductPhoto>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductPhoto>|ResultSetInterface<ProductPhoto> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductPhoto>|ResultSetInterface<ProductPhoto>|false deleteMany(iterable $entities, array $options = [])
|
||||
@@ -37,16 +30,15 @@ use Psr\SimpleCache\CacheInterface;
|
||||
*
|
||||
* @mixin TimestampBehavior
|
||||
*/
|
||||
class ProductPhotosTable extends Table
|
||||
{
|
||||
class ProductPhotosTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('product_photos');
|
||||
@@ -54,7 +46,7 @@ class ProductPhotosTable extends Table
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ProductPhotos.entity', 'CakeProducts\Model\Entity\ProductPhoto')
|
||||
Configure::read('CakeProducts.ProductPhotos.entity', 'CakeProducts\Model\Entity\ProductPhoto'),
|
||||
);
|
||||
|
||||
$this->addBehavior('Timestamp');
|
||||
@@ -105,11 +97,10 @@ class ProductPhotosTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->uuid('product_id')
|
||||
->allowEmptyString('product_id');
|
||||
@@ -158,15 +149,15 @@ class ProductPhotosTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->existsIn(['product_id'], 'Products'), ['errorField' => 'product_id']);
|
||||
$rules->add($rules->existsIn(['product_sku_id'], 'ProductSkus'), ['errorField' => 'product_sku_id']);
|
||||
$rules->add($rules->existsIn(['product_category_id'], 'ProductCategories'), ['errorField' => 'product_category_id']);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,16 +3,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\ProductSkuVariantValue;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ProductSkuVariantValues Model
|
||||
@@ -21,30 +14,29 @@ use Psr\SimpleCache\CacheInterface;
|
||||
* @property ProductCategoryVariantsTable&BelongsTo $ProductCategoryVariants
|
||||
* @property ProductCategoryVariantOptionsTable&BelongsTo $ProductCategoryVariantOptions
|
||||
*
|
||||
* @method ProductSkuVariantValue newEmptyEntity()
|
||||
* @method ProductSkuVariantValue newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductSkuVariantValue newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ProductSkuVariantValue newEntity()
|
||||
* @method array<ProductSkuVariantValue> newEntities(array $data, array $options = [])
|
||||
* @method ProductSkuVariantValue get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ProductSkuVariantValue findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ProductSkuVariantValue patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductSkuVariantValue get()
|
||||
* @method \CakeProducts\Model\Entity\ProductSkuVariantValue findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ProductSkuVariantValue patchEntity()
|
||||
* @method array<ProductSkuVariantValue> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ProductSkuVariantValue|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ProductSkuVariantValue saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductSkuVariantValue saveOrFail()
|
||||
* @method iterable<ProductSkuVariantValue>|ResultSetInterface<ProductSkuVariantValue>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductSkuVariantValue>|ResultSetInterface<ProductSkuVariantValue> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductSkuVariantValue>|ResultSetInterface<ProductSkuVariantValue>|false deleteMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductSkuVariantValue>|ResultSetInterface<ProductSkuVariantValue> deleteManyOrFail(iterable $entities, array $options = [])
|
||||
*/
|
||||
class ProductSkuVariantValuesTable extends Table
|
||||
{
|
||||
class ProductSkuVariantValuesTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('product_sku_variant_values');
|
||||
@@ -72,11 +64,10 @@ class ProductSkuVariantValuesTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->uuid('product_sku_id')
|
||||
->notEmptyString('product_sku_id');
|
||||
@@ -96,11 +87,10 @@ class ProductSkuVariantValuesTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->existsIn(['product_sku_id'], 'ProductSkus'), ['errorField' => 'product_sku_id']);
|
||||
|
||||
// @TODO why not working?? causing tests to fail / associated variant values not saving on product-skus/add
|
||||
@@ -109,4 +99,5 @@ class ProductSkuVariantValuesTable extends Table
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,33 +4,24 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use CakeProducts\Model\Table\ProductsTable;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Behavior\TimestampBehavior;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\ProductSku;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ProductSkus Model
|
||||
*
|
||||
* @property ProductsTable&BelongsTo $Products
|
||||
*
|
||||
* @method ProductSku newEmptyEntity()
|
||||
* @method ProductSku newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductSku newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ProductSku newEntity()
|
||||
* @method array<ProductSku> newEntities(array $data, array $options = [])
|
||||
* @method ProductSku get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ProductSku findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ProductSku patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductSku get()
|
||||
* @method \CakeProducts\Model\Entity\ProductSku findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ProductSku patchEntity()
|
||||
* @method array<ProductSku> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ProductSku|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ProductSku saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductSku saveOrFail()
|
||||
* @method iterable<ProductSku>|ResultSetInterface<ProductSku>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductSku>|ResultSetInterface<ProductSku> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductSku>|ResultSetInterface<ProductSku>|false deleteMany(iterable $entities, array $options = [])
|
||||
@@ -38,16 +29,15 @@ use Psr\SimpleCache\CacheInterface;
|
||||
*
|
||||
* @mixin TimestampBehavior
|
||||
*/
|
||||
class ProductSkusTable extends Table
|
||||
{
|
||||
class ProductSkusTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('product_skus');
|
||||
@@ -55,7 +45,7 @@ class ProductSkusTable extends Table
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ProductSkus.entity', 'CakeProducts\Model\Entity\ProductSku')
|
||||
Configure::read('CakeProducts.ProductSkus.entity', 'CakeProducts\Model\Entity\ProductSku'),
|
||||
);
|
||||
|
||||
$this->addBehavior('Timestamp');
|
||||
@@ -99,11 +89,10 @@ class ProductSkusTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->uuid('product_id')
|
||||
->notEmptyString('product_id');
|
||||
@@ -138,14 +127,14 @@ class ProductSkusTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->existsIn(['product_id'], 'Products'), ['errorField' => 'product_id']);
|
||||
$rules->add($rules->isUnique(['sku'], 'SKU must be unique'), ['errorField' => 'sku']);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,18 +3,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use CakeProducts\Model\Entity\ProductVariant;
|
||||
use CakeProducts\Model\Table\ProductCategoryVariantsTable;
|
||||
use CakeProducts\Model\Table\ProductsTable;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* ProductVariants Model
|
||||
@@ -22,30 +13,29 @@ use Psr\SimpleCache\CacheInterface;
|
||||
* @property ProductCategoryVariantsTable&BelongsTo $ProductCategoryVariants
|
||||
* @property ProductsTable&BelongsTo $Products
|
||||
*
|
||||
* @method ProductVariant newEmptyEntity()
|
||||
* @method ProductVariant newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductVariant newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\ProductVariant newEntity()
|
||||
* @method array<ProductVariant> newEntities(array $data, array $options = [])
|
||||
* @method ProductVariant get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method ProductVariant findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method ProductVariant patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductVariant get()
|
||||
* @method \CakeProducts\Model\Entity\ProductVariant findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\ProductVariant patchEntity()
|
||||
* @method array<ProductVariant> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method ProductVariant|false save(EntityInterface $entity, array $options = [])
|
||||
* @method ProductVariant saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\ProductVariant saveOrFail()
|
||||
* @method iterable<ProductVariant>|ResultSetInterface<ProductVariant>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductVariant>|ResultSetInterface<ProductVariant> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductVariant>|ResultSetInterface<ProductVariant>|false deleteMany(iterable $entities, array $options = [])
|
||||
* @method iterable<ProductVariant>|ResultSetInterface<ProductVariant> deleteManyOrFail(iterable $entities, array $options = [])
|
||||
*/
|
||||
class ProductVariantsTable extends Table
|
||||
{
|
||||
class ProductVariantsTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('product_variants');
|
||||
@@ -73,11 +63,10 @@ class ProductVariantsTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->scalar('name')
|
||||
->maxLength('name', 255)
|
||||
@@ -104,14 +93,14 @@ class ProductVariantsTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->existsIn(['product_category_variant_id'], 'ProductCategoryVariants'), ['errorField' => 'product_category_variant_id']);
|
||||
$rules->add($rules->existsIn(['product_id'], 'Products'), ['errorField' => 'product_id']);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,47 +5,39 @@ namespace CakeProducts\Model\Table;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Database\Type\EnumType;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
use CakeProducts\Model\Entity\Product;
|
||||
use CakeProducts\Model\Enum\ProductProductTypeId;
|
||||
use Closure;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
/**
|
||||
* Products Model
|
||||
*
|
||||
* @property ProductCategoriesTable&BelongsTo $ProductCategories
|
||||
*
|
||||
* @method Product newEmptyEntity()
|
||||
* @method Product newEntity(array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\Product newEmptyEntity()
|
||||
* @method \CakeProducts\Model\Entity\Product newEntity()
|
||||
* @method array<Product> newEntities(array $data, array $options = [])
|
||||
* @method Product get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
|
||||
* @method Product findOrCreate($search, ?callable $callback = null, array $options = [])
|
||||
* @method Product patchEntity(EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\Product get()
|
||||
* @method \CakeProducts\Model\Entity\Product findOrCreate()
|
||||
* @method \CakeProducts\Model\Entity\Product patchEntity()
|
||||
* @method array<Product> patchEntities(iterable $entities, array $data, array $options = [])
|
||||
* @method Product|false save(EntityInterface $entity, array $options = [])
|
||||
* @method Product saveOrFail(EntityInterface $entity, array $options = [])
|
||||
* @method \CakeProducts\Model\Entity\Product saveOrFail()
|
||||
* @method iterable<Product>|ResultSetInterface<Product>|false saveMany(iterable $entities, array $options = [])
|
||||
* @method iterable<Product>|ResultSetInterface<Product> saveManyOrFail(iterable $entities, array $options = [])
|
||||
* @method iterable<Product>|ResultSetInterface<Product>|false deleteMany(iterable $entities, array $options = [])
|
||||
* @method iterable<Product>|ResultSetInterface<Product> deleteManyOrFail(iterable $entities, array $options = [])
|
||||
*/
|
||||
class ProductsTable extends Table
|
||||
{
|
||||
class ProductsTable extends Table {
|
||||
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config): void
|
||||
{
|
||||
public function initialize(array $config): void {
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('products');
|
||||
@@ -53,7 +45,7 @@ class ProductsTable extends Table
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.Products.entity', 'CakeProducts\Model\Entity\Product')
|
||||
Configure::read('CakeProducts.Products.entity', 'CakeProducts\Model\Entity\Product'),
|
||||
);
|
||||
|
||||
$this->belongsTo('ProductCategories', [
|
||||
@@ -113,11 +105,10 @@ class ProductsTable extends Table
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param Validator $validator Validator instance.
|
||||
* @return Validator
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator): Validator
|
||||
{
|
||||
public function validationDefault(Validator $validator): Validator {
|
||||
$validator
|
||||
->scalar('name')
|
||||
->maxLength('name', 255)
|
||||
@@ -144,15 +135,15 @@ class ProductsTable extends Table
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param RulesChecker $rules The rules object to be modified.
|
||||
* @return RulesChecker
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
public function buildRules(RulesChecker $rules): RulesChecker {
|
||||
$rules->add($rules->isUnique(['product_category_id', 'name']), ['errorField' => 'product_category_id']);
|
||||
$rules->add($rules->existsIn(['product_category_id'], 'ProductCategories'), ['errorField' => 'product_category_id']);
|
||||
// $rules->add($rules->validCount('product_attributes', 0, '<=', 'You must not have any tags'));
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ExternalProductCatalogsFixture
|
||||
*/
|
||||
class ExternalProductCatalogsFixture extends TestFixture
|
||||
{
|
||||
class ExternalProductCatalogsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '115153f3-2f59-4234-8ff8-e1b205769999',
|
||||
@@ -28,4 +27,5 @@ class ExternalProductCatalogsFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ExternalProductCatalogsProductCatalogsFixture
|
||||
*/
|
||||
class ExternalProductCatalogsProductCatalogsFixture extends TestFixture
|
||||
{
|
||||
class ExternalProductCatalogsProductCatalogsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => 1,
|
||||
@@ -29,4 +28,5 @@ class ExternalProductCatalogsProductCatalogsFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,18 +8,16 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductAttributesFixture
|
||||
*/
|
||||
class ProductAttributesFixture extends TestFixture
|
||||
{
|
||||
class ProductAttributesFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
$this->records = [
|
||||
|
||||
];
|
||||
public function init(): void {
|
||||
$this->records = [];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductCatalogsFixture
|
||||
*/
|
||||
class ProductCatalogsFixture extends TestFixture
|
||||
{
|
||||
class ProductCatalogsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '115153f3-2f59-4234-8ff8-e1b205761428',
|
||||
@@ -35,4 +34,5 @@ class ProductCatalogsFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductCategoriesFixture
|
||||
*/
|
||||
class ProductCategoriesFixture extends TestFixture
|
||||
{
|
||||
class ProductCategoriesFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => 1,
|
||||
@@ -105,4 +104,5 @@ class ProductCategoriesFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductCategoryAttributeOptionsFixture
|
||||
*/
|
||||
class ProductCategoryAttributeOptionsFixture extends TestFixture
|
||||
{
|
||||
class ProductCategoryAttributeOptionsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => 'e06f1723-2456-483a-b3c4-004603e032a8',
|
||||
@@ -41,8 +40,9 @@ class ProductCategoryAttributeOptionsFixture extends TestFixture
|
||||
'attribute_label' => 'Green',
|
||||
'enabled' => 1,
|
||||
'deleted' => null,
|
||||
]
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductCategoryAttributesFixture
|
||||
*/
|
||||
class ProductCategoryAttributesFixture extends TestFixture
|
||||
{
|
||||
class ProductCategoryAttributesFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
|
||||
@@ -29,4 +28,5 @@ class ProductCategoryAttributesFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductCategoryVariantsFixture
|
||||
*/
|
||||
class ProductCategoryVariantOptionsFixture extends TestFixture
|
||||
{
|
||||
class ProductCategoryVariantOptionsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d23',
|
||||
@@ -37,7 +36,6 @@ class ProductCategoryVariantOptionsFixture extends TestFixture
|
||||
'enabled' => 1,
|
||||
],
|
||||
|
||||
|
||||
[
|
||||
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d21',
|
||||
'variant_value' => '12AWG',
|
||||
@@ -96,4 +94,5 @@ class ProductCategoryVariantOptionsFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductCategoryVariantsFixture
|
||||
*/
|
||||
class ProductCategoryVariantsFixture extends TestFixture
|
||||
{
|
||||
class ProductCategoryVariantsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78111',
|
||||
@@ -50,4 +49,5 @@ class ProductCategoryVariantsFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductPhotosFixture
|
||||
*/
|
||||
class ProductPhotosFixture extends TestFixture
|
||||
{
|
||||
class ProductPhotosFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f58',
|
||||
@@ -120,4 +119,5 @@ class ProductPhotosFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductSkuVariantValuesFixture
|
||||
*/
|
||||
class ProductSkuVariantValuesFixture extends TestFixture
|
||||
{
|
||||
class ProductSkuVariantValuesFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
@@ -22,8 +22,7 @@ class ProductSkuVariantValuesFixture extends TestFixture
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '98b609d8-1d4f-484c-a13a-6adb7102da56',
|
||||
@@ -34,4 +33,5 @@ class ProductSkuVariantValuesFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,21 +8,21 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductSkusFixture
|
||||
*/
|
||||
class ProductSkusFixture extends TestFixture
|
||||
{
|
||||
class ProductSkusFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public string $table = 'product_skus';
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '3a477e3e-7977-4813-81f6-f85949613979',
|
||||
@@ -38,4 +38,5 @@ class ProductSkusFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductVariantsFixture
|
||||
*/
|
||||
class ProductVariantsFixture extends TestFixture
|
||||
{
|
||||
class ProductVariantsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '2e6e4031-c430-4d07-b8d6-a4e759b72568',
|
||||
@@ -45,8 +44,9 @@ class ProductVariantsFixture extends TestFixture
|
||||
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
|
||||
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05318',
|
||||
'enabled' => 1,
|
||||
]
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* ProductsFixture
|
||||
*/
|
||||
class ProductsFixture extends TestFixture
|
||||
{
|
||||
class ProductsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
|
||||
@@ -35,4 +34,5 @@ class ProductsFixture extends TestFixture
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,12 +14,11 @@ use RecursiveIteratorIterator;
|
||||
*
|
||||
* Used to make logging in easier and to handle folder structure for product images
|
||||
*/
|
||||
class BaseControllerTest extends TestCase
|
||||
{
|
||||
class BaseControllerTest extends TestCase {
|
||||
|
||||
use IntegrationTestTrait;
|
||||
|
||||
public function loginUserByRole(string $role = 'admin'): void
|
||||
{
|
||||
public function loginUserByRole(string $role = 'admin'): void {
|
||||
$this->session(['Auth.User.id' => 1]);
|
||||
$this->session(['Auth.id' => 1]);
|
||||
}
|
||||
@@ -27,8 +26,7 @@ class BaseControllerTest extends TestCase
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testTest()
|
||||
{
|
||||
public function testTest() {
|
||||
$this->assertEquals(1, 1);
|
||||
}
|
||||
|
||||
@@ -37,12 +35,11 @@ class BaseControllerTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
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 . 'uploads' . DS .
|
||||
'images' . DS . 'products' . DS . 'cfc98a9a-29b2-44c8-b587-8156adc05317';
|
||||
$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)) {
|
||||
if (!file_exists($productsFolder)) {
|
||||
@@ -52,17 +49,17 @@ class BaseControllerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
parent::tearDown(); // TODO: Change the autogenerated stub
|
||||
|
||||
$path = Configure::readOrFail('CakeProducts.photos.directory');
|
||||
if (file_exists($path)) {
|
||||
$di = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
|
||||
$ri = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ( $ri as $file ) {
|
||||
foreach ($ri as $file) {
|
||||
$file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,25 +4,20 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Controller\ExternalProductCatalogsController;
|
||||
use CakeProducts\Model\Table\ExternalProductCatalogsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ExternalProductCatalogsController Test Case
|
||||
*/
|
||||
#[CoversClass(ExternalProductCatalogsController::class)]
|
||||
class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
{
|
||||
class ExternalProductCatalogsControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject table
|
||||
*
|
||||
* @var ExternalProductCatalogsTable|Table
|
||||
* @var \CakeProducts\Model\Table\ExternalProductCatalogsTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ExternalProductCatalogs;
|
||||
|
||||
@@ -42,8 +37,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
@@ -56,8 +50,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ExternalProductCatalogs);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -69,12 +62,11 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::index()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGet(): void
|
||||
{
|
||||
public function testIndexGet(): void {
|
||||
Log::debug('inside testIndexGet ExternalProductCatalogsControllerTest');
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -92,12 +84,11 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::view()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGet(): void
|
||||
{
|
||||
public function testViewGet(): void {
|
||||
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -116,12 +107,11 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void
|
||||
{
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->ExternalProductCatalogs->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -143,12 +133,11 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostSuccess(): void
|
||||
{
|
||||
public function testAddPostSuccess(): void {
|
||||
$linksTable = TableRegistry::getTableLocator()->get('CakeProducts.ExternalProductCatalogsProductCatalogs');
|
||||
$cntBefore = $this->ExternalProductCatalogs->find()->count();
|
||||
$linksBefore = $linksTable->find()->count();
|
||||
@@ -165,7 +154,7 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
'enabled' => true,
|
||||
'external_product_catalogs_product_catalogs' => [
|
||||
['product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428'],
|
||||
]
|
||||
],
|
||||
];
|
||||
$this->post($url, $data);
|
||||
$this->assertResponseCode(302);
|
||||
@@ -184,12 +173,11 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostFailure(): void
|
||||
{
|
||||
public function testAddPostFailure(): void {
|
||||
$cntBefore = $this->ExternalProductCatalogs->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -217,12 +205,11 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGet(): void
|
||||
{
|
||||
public function testEditGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -240,12 +227,11 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutSuccess(): void
|
||||
{
|
||||
public function testEditPutSuccess(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
|
||||
$before = $this->ExternalProductCatalogs->get($id);
|
||||
@@ -276,12 +262,11 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutFailure(): void
|
||||
{
|
||||
public function testEditPutFailure(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
|
||||
$before = $this->ExternalProductCatalogs->get($id);
|
||||
@@ -310,12 +295,11 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController::delete()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
public function testDelete(): void {
|
||||
$cntBefore = $this->ExternalProductCatalogs->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -332,4 +316,5 @@ class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
$cntAfter = $this->ExternalProductCatalogs->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-18
@@ -4,25 +4,21 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ExternalProductCatalogsProductCatalogsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController Test Case
|
||||
*/
|
||||
#[CoversClass(ExternalProductCatalogsProductCatalogsController::class)]
|
||||
class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControllerTest
|
||||
{
|
||||
class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject table
|
||||
*
|
||||
* @var ExternalProductCatalogsProductCatalogsTable|Table
|
||||
* @var \CakeProducts\Model\Table\ExternalProductCatalogsProductCatalogsTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ExternalProductCatalogsProductCatalogs;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
@@ -39,8 +35,7 @@ class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControlle
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
@@ -53,8 +48,7 @@ class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControlle
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ExternalProductCatalogsProductCatalogs);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -66,12 +60,11 @@ class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControlle
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void
|
||||
{
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->ExternalProductCatalogsProductCatalogs->find()->count();
|
||||
|
||||
// $this->loginUserByRole('admin');
|
||||
@@ -93,12 +86,11 @@ class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControlle
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController::delete()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
public function testDelete(): void {
|
||||
$cntBeforeWithTrashed = $this->ExternalProductCatalogsProductCatalogs->find('withTrashed')->count();
|
||||
$cntBefore = $this->ExternalProductCatalogsProductCatalogs->find()->count();
|
||||
|
||||
@@ -118,4 +110,5 @@ class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControlle
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
$this->assertEquals($cntBeforeWithTrashed, $cntAfterWithTrashed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,24 +3,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\ORM\Table;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Controller\ProductCatalogsController;
|
||||
use CakeProducts\Model\Table\ProductCatalogsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductCatalogsController Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCatalogsController::class)]
|
||||
class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
{
|
||||
class ProductCatalogsControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject table
|
||||
*
|
||||
* @var ProductCatalogsTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductCatalogsTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ProductCatalogs;
|
||||
|
||||
@@ -39,8 +35,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
@@ -54,8 +49,7 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductCatalogs);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -67,12 +61,11 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCatalogsController::index()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGet(): void
|
||||
{
|
||||
public function testIndexGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -89,12 +82,11 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCatalogsController::view()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGet(): void
|
||||
{
|
||||
public function testViewGet(): void {
|
||||
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -113,12 +105,11 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCatalogsController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void
|
||||
{
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->ProductCatalogs->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -140,12 +131,11 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCatalogsController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostSuccess(): void
|
||||
{
|
||||
public function testAddPostSuccess(): void {
|
||||
$cntBefore = $this->ProductCatalogs->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -173,12 +163,11 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCatalogsController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostFailure(): void
|
||||
{
|
||||
public function testAddPostFailure(): void {
|
||||
$cntBefore = $this->ProductCatalogs->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -205,12 +194,11 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCatalogsController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGet(): void
|
||||
{
|
||||
public function testEditGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
|
||||
$url = [
|
||||
@@ -229,12 +217,11 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCatalogsController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutSuccess(): void
|
||||
{
|
||||
public function testEditPutSuccess(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
|
||||
// $before = $this->ProductCatalogs->get($id);
|
||||
@@ -267,12 +254,11 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCatalogsController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutFailure(): void
|
||||
{
|
||||
public function testEditPutFailure(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
|
||||
$before = $this->ProductCatalogs->get($id);
|
||||
@@ -301,12 +287,11 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCatalogsController::delete()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
public function testDelete(): void {
|
||||
$cntBefore = $this->ProductCatalogs->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -324,4 +309,5 @@ class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
$cntAfter = $this->ProductCatalogs->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,24 +3,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\ORM\Table;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Controller\ProductCategoriesController;
|
||||
use CakeProducts\Model\Table\ProductCategoriesTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductCategoriesController Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoriesController::class)]
|
||||
class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
{
|
||||
class ProductCategoriesControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject table
|
||||
*
|
||||
* @var ProductCategoriesTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductCategoriesTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ProductCategories;
|
||||
|
||||
@@ -39,8 +34,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
@@ -53,8 +47,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductCategories);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -65,13 +58,11 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoriesController::index
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGet(): void
|
||||
{
|
||||
public function testIndexGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -87,13 +78,11 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoriesController::view
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGet(): void
|
||||
{
|
||||
public function testViewGet(): void {
|
||||
$id = 1;
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -111,13 +100,11 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoriesController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void
|
||||
{
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->ProductCategories->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -138,13 +125,11 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoriesController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostSuccess(): void
|
||||
{
|
||||
public function testAddPostSuccess(): void {
|
||||
$cntBefore = $this->ProductCategories->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -173,13 +158,11 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoriesController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostFailure(): void
|
||||
{
|
||||
public function testAddPostFailure(): void {
|
||||
$cntBefore = $this->ProductCategories->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -207,13 +190,11 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoriesController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGet(): void
|
||||
{
|
||||
public function testEditGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -230,13 +211,11 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoriesController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutSuccess(): void
|
||||
{
|
||||
public function testEditPutSuccess(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = 1;
|
||||
$before = $this->ProductCategories->get($id);
|
||||
@@ -272,13 +251,11 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoriesController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutFailure(): void
|
||||
{
|
||||
public function testEditPutFailure(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = 1;
|
||||
$before = $this->ProductCategories->get($id);
|
||||
@@ -306,14 +283,12 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
* Test delete method
|
||||
*
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
*@throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoriesController::delete
|
||||
*@throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
public function testDelete(): void {
|
||||
$cntBefore = $this->ProductCategories->find()->count();
|
||||
$cntBeforeWithTrashed = $this->ProductCategories->find('withTrashed')->count();
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -333,4 +308,5 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
$this->assertEquals($cntBefore - 2, $cntAfter); // has 1 child category
|
||||
$this->assertEquals($cntBeforeWithTrashed, $cntAfterWithTrashed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,22 +3,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\ORM\Table;
|
||||
use CakeProducts\Controller\ProductCategoryAttributeOptionsController;
|
||||
use CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductCategoryAttributeOptionsController Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoryAttributeOptionsController::class)]
|
||||
class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
|
||||
{
|
||||
class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var ProductCategoryAttributeOptionsTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ProductCategoryAttributeOptions;
|
||||
|
||||
@@ -37,8 +35,7 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
@@ -51,8 +48,7 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductCategoryAttributeOptions);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -63,13 +59,11 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributeOptionsController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void
|
||||
{
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -90,13 +84,11 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributeOptionsController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostHasNoEffect(): void
|
||||
{
|
||||
public function testAddPostHasNoEffect(): void {
|
||||
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -118,13 +110,11 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
*@throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributeOptionsController::delete
|
||||
*@throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
public function testDelete(): void {
|
||||
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -141,4 +131,5 @@ class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
|
||||
$cntAfter = $this->ProductCategoryAttributeOptions->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,24 +3,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\ORM\Table;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Controller\ProductCategoryAttributesController;
|
||||
use CakeProducts\Model\Table\ProductCategoryAttributesTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductCategoryAttributesController Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoryAttributesController::class)]
|
||||
class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
{
|
||||
class ProductCategoryAttributesControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var ProductCategoryAttributesTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductCategoryAttributesTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ProductCategoryAttributes;
|
||||
|
||||
@@ -39,8 +35,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
@@ -53,8 +48,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductCategoryAttributes);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -65,13 +59,11 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController::index
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGet(): void
|
||||
{
|
||||
public function testIndexGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -87,13 +79,11 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController::view
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGet(): void
|
||||
{
|
||||
public function testViewGet(): void {
|
||||
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -111,13 +101,11 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void
|
||||
{
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->ProductCategoryAttributes->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -138,13 +126,11 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostSuccess(): void
|
||||
{
|
||||
public function testAddPostSuccess(): void {
|
||||
$cntBefore = $this->ProductCategoryAttributes->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -172,13 +158,11 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostSuccessConstrainedWithOptions(): void
|
||||
{
|
||||
public function testAddPostSuccessConstrainedWithOptions(): void {
|
||||
$cntBefore = $this->ProductCategoryAttributes->find()->count();
|
||||
$cntOptionsBefore = $this->ProductCategoryAttributes->ProductCategoryAttributeOptions->find()->count();
|
||||
|
||||
@@ -203,7 +187,7 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
'attribute_value' => 'L',
|
||||
'attribute_label' => 'L',
|
||||
'enabled' => true,
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->post($url, $data);
|
||||
@@ -222,13 +206,11 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostFailure(): void
|
||||
{
|
||||
public function testAddPostFailure(): void {
|
||||
$cntBefore = $this->ProductCategoryAttributes->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -255,13 +237,11 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGet(): void
|
||||
{
|
||||
public function testEditGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -278,13 +258,11 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutSuccess(): void
|
||||
{
|
||||
public function testEditPutSuccess(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
|
||||
$before = $this->ProductCategoryAttributes->get($id);
|
||||
@@ -315,13 +293,11 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutFailure(): void
|
||||
{
|
||||
public function testEditPutFailure(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
|
||||
$before = $this->ProductCategoryAttributes->get($id);
|
||||
@@ -348,14 +324,12 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
* Test delete method
|
||||
*
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
*@throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController::delete
|
||||
*@throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
public function testDelete(): void {
|
||||
$cntBefore = $this->ProductCategoryAttributes->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -372,4 +346,5 @@ class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
$cntAfter = $this->ProductCategoryAttributes->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,33 +3,31 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\ORM\Table;
|
||||
use CakeProducts\Controller\ProductCategoryVariantsController;
|
||||
use CakeProducts\Model\Table\ProductCategoryAttributesTable;
|
||||
use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable;
|
||||
use CakeProducts\Model\Table\ProductCategoryVariantsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductCategoryVariantsController Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoryVariantsController::class)]
|
||||
class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
{
|
||||
class ProductCategoryVariantsControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var ProductCategoryVariantsTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductCategoryVariantsTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ProductCategoryVariants;
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var ProductCategoryVariantOptionsTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductCategoryVariantOptionsTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ProductCategoryVariantOptions;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
@@ -50,8 +48,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->disableErrorHandlerMiddleware();
|
||||
|
||||
@@ -67,8 +64,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductCategoryVariants);
|
||||
unset($this->ProductCategoryVariantOptions);
|
||||
|
||||
@@ -81,12 +77,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController::index()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGet(): void
|
||||
{
|
||||
public function testIndexGet(): void {
|
||||
//$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -103,12 +98,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController::view()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGet(): void
|
||||
{
|
||||
public function testViewGet(): void {
|
||||
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
|
||||
//$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -127,12 +121,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void
|
||||
{
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->ProductCategoryVariants->find()->count();
|
||||
|
||||
//$this->loginUserByRole('admin');
|
||||
@@ -154,12 +147,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostLoggedInSuccess(): void
|
||||
{
|
||||
public function testAddPostLoggedInSuccess(): void {
|
||||
$cntBefore = $this->ProductCategoryVariants->find()->count();
|
||||
$cntBeforeOptions = $this->ProductCategoryVariantOptions->find()->count();
|
||||
|
||||
@@ -185,7 +177,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
'variant_label' => 'XXL',
|
||||
'enabled' => true,
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
$this->post($url, $data);
|
||||
$this->assertResponseCode(302);
|
||||
@@ -203,12 +195,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostLoggedInFailure(): void
|
||||
{
|
||||
public function testAddPostLoggedInFailure(): void {
|
||||
$cntBefore = $this->ProductCategoryVariants->find()->count();
|
||||
|
||||
//$this->loginUserByRole('admin');
|
||||
@@ -235,12 +226,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* Tests the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGet(): void
|
||||
{
|
||||
public function testEditGet(): void {
|
||||
//$this->loginUserByRole('admin');
|
||||
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
|
||||
|
||||
@@ -260,12 +250,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutLoggedInSuccess(): void
|
||||
{
|
||||
public function testEditPutLoggedInSuccess(): void {
|
||||
//$this->loginUserByRole('admin');
|
||||
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
|
||||
$before = $this->ProductCategoryVariants->get($id);
|
||||
@@ -296,12 +285,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutLoggedInSuccessSystemVariant(): void
|
||||
{
|
||||
public function testEditPutLoggedInSuccessSystemVariant(): void {
|
||||
//$this->loginUserByRole('admin');
|
||||
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78222'; // subscription length
|
||||
$before = $this->ProductCategoryVariants->get($id);
|
||||
@@ -367,12 +355,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutLoggedInFailure(): void
|
||||
{
|
||||
public function testEditPutLoggedInFailure(): void {
|
||||
//$this->loginUserByRole('admin');
|
||||
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
|
||||
$before = $this->ProductCategoryVariants->get($id);
|
||||
@@ -400,12 +387,11 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController::delete()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
public function testDelete(): void {
|
||||
$cntBefore = $this->ProductCategoryVariants->find()->count();
|
||||
|
||||
//$this->loginUserByRole('admin');
|
||||
@@ -424,4 +410,5 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
$cntAfter = $this->ProductCategoryVariants->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,28 +4,22 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\ORM\Table;
|
||||
use CakeProducts\Controller\ProductPhotosController;
|
||||
use CakeProducts\Model\Table\ProductPhotosTable;
|
||||
use CakeProducts\Model\Table\ProductsTable;
|
||||
use FilesystemIterator;
|
||||
use Laminas\Diactoros\UploadedFile;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use const UPLOAD_ERR_OK;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductPhotosController Test Case
|
||||
*/
|
||||
#[CoversClass(ProductPhotosController::class)]
|
||||
class ProductPhotosControllerTest extends BaseControllerTest
|
||||
{
|
||||
class ProductPhotosControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject table
|
||||
*
|
||||
* @var ProductPhotosTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductPhotosTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ProductPhotos;
|
||||
|
||||
@@ -46,8 +40,7 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('ProductPhotos') ? [] : ['className' => ProductPhotosTable::class];
|
||||
$this->ProductPhotos = $this->getTableLocator()->get('ProductPhotos', $config);
|
||||
@@ -58,8 +51,7 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductPhotos);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -70,13 +62,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::index
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGetLoggedIn(): void
|
||||
{
|
||||
public function testIndexGetLoggedIn(): void {
|
||||
// $this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -92,13 +82,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::view
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGetLoggedIn(): void
|
||||
{
|
||||
public function testViewGetLoggedIn(): void {
|
||||
$id = '2c386086-f4c5-4093-bea5-ee9c29479f58';
|
||||
// $this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -116,13 +104,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGetLoggedIn(): void
|
||||
{
|
||||
public function testAddGetLoggedIn(): void {
|
||||
$cntBefore = $this->ProductPhotos->find()->count();
|
||||
|
||||
// $this->loginUserByRole('admin');
|
||||
@@ -143,13 +129,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostLoggedInSuccessDefaultPhoto(): void
|
||||
{
|
||||
public function testAddPostLoggedInSuccessDefaultPhoto(): void {
|
||||
$cntBefore = $this->ProductPhotos->find()->count();
|
||||
|
||||
// $this->loginUserByRole('admin');
|
||||
@@ -178,7 +162,7 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
12345, // the filesize in bytes
|
||||
UPLOAD_ERR_OK, // the upload/error status
|
||||
'cake_icon.png', // the filename as sent by the client
|
||||
'image/png' // the mimetype as sent by the client
|
||||
'image/png', // the mimetype as sent by the client
|
||||
);
|
||||
$this->configRequest([
|
||||
'files' => [
|
||||
@@ -222,13 +206,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostLoggedInSuccessDefaultCategoryPhoto(): void
|
||||
{
|
||||
public function testAddPostLoggedInSuccessDefaultCategoryPhoto(): void {
|
||||
$cntBefore = $this->ProductPhotos->find()->count();
|
||||
|
||||
// $this->loginUserByRole('admin');
|
||||
@@ -253,13 +235,12 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
|
||||
$this->assertEquals(1, $primaryCategoryPhotosCountBefore);
|
||||
|
||||
|
||||
$image = new UploadedFile(
|
||||
$toUseFile, // stream or path to file representing the temp file
|
||||
12345, // the filesize in bytes
|
||||
UPLOAD_ERR_OK, // the upload/error status
|
||||
'cake_icon.png', // the filename as sent by the client
|
||||
'image/png' // the mimetype as sent by the client
|
||||
'image/png', // the mimetype as sent by the client
|
||||
);
|
||||
$this->configRequest([
|
||||
'files' => [
|
||||
@@ -303,15 +284,12 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @TODO handle toggle behavior when scope field is nullable
|
||||
*
|
||||
* @todo handle toggle behavior when scope field is nullable
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::add
|
||||
* @throws \PHPUnit\Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostLoggedInSuccessDefaultSkuPhoto(): void
|
||||
{
|
||||
public function testAddPostLoggedInSuccessDefaultSkuPhoto(): void {
|
||||
$cntBefore = $this->ProductPhotos->find()->count();
|
||||
|
||||
// $this->loginUserByRole('admin');
|
||||
@@ -336,13 +314,12 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
|
||||
$this->assertEquals(1, $primarySkuPhotosCountBefore);
|
||||
|
||||
|
||||
$image = new UploadedFile(
|
||||
$toUseFile, // stream or path to file representing the temp file
|
||||
12345, // the filesize in bytes
|
||||
UPLOAD_ERR_OK, // the upload/error status
|
||||
'cake_icon.png', // the filename as sent by the client
|
||||
'image/png' // the mimetype as sent by the client
|
||||
'image/png', // the mimetype as sent by the client
|
||||
);
|
||||
$this->configRequest([
|
||||
'files' => [
|
||||
@@ -387,13 +364,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostLoggedInFailure(): void
|
||||
{
|
||||
public function testAddPostLoggedInFailure(): void {
|
||||
$cntBefore = $this->ProductPhotos->find()->count();
|
||||
|
||||
// $this->loginUserByRole('admin');
|
||||
@@ -402,8 +377,7 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
'controller' => 'ProductPhotos',
|
||||
'action' => 'add',
|
||||
];
|
||||
$data = [
|
||||
];
|
||||
$data = [];
|
||||
$this->post($url, $data);
|
||||
$this->assertResponseCode(200);
|
||||
|
||||
@@ -416,13 +390,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGetLoggedIn(): void
|
||||
{
|
||||
public function testEditGetLoggedIn(): void {
|
||||
// $this->loginUserByRole('admin');
|
||||
$id = '2c386086-f4c5-4093-bea5-ee9c29479f58';
|
||||
|
||||
@@ -441,13 +413,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutLoggedInSuccess(): void
|
||||
{
|
||||
public function testEditPutLoggedInSuccess(): void {
|
||||
// $this->loginUserByRole('admin');
|
||||
$id = '2c386086-f4c5-4093-bea5-ee9c29479f58';
|
||||
$before = $this->ProductPhotos->get($id);
|
||||
@@ -479,13 +449,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutLoggedInFailure(): void
|
||||
{
|
||||
public function testEditPutLoggedInFailure(): void {
|
||||
// $this->loginUserByRole('admin');
|
||||
$id = '2c386086-f4c5-4093-bea5-ee9c29479f58';
|
||||
$before = $this->ProductPhotos->get($id);
|
||||
@@ -514,13 +482,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::delete
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testDeleteLoggedInDefaultProductPhoto(): void
|
||||
{
|
||||
public function testDeleteLoggedInDefaultProductPhoto(): void {
|
||||
$cntBefore = $this->ProductPhotos->find()->count();
|
||||
$id = '2c386086-f4c5-4093-bea5-ee9c29479f58';
|
||||
$productId = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
|
||||
@@ -553,13 +519,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::delete
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testDeleteLoggedInDefaultCategoryPhoto(): void
|
||||
{
|
||||
public function testDeleteLoggedInDefaultCategoryPhoto(): void {
|
||||
$cntBefore = $this->ProductPhotos->find()->count();
|
||||
$id = '2c386086-f4c5-4093-bea5-ee9c29479f51';
|
||||
$productId = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
|
||||
@@ -594,13 +558,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::delete
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testDeleteLoggedInDefaultSkuPhoto(): void
|
||||
{
|
||||
public function testDeleteLoggedInDefaultSkuPhoto(): void {
|
||||
$cntBefore = $this->ProductPhotos->find()->count();
|
||||
$id = '2c386086-f4c5-4093-bea5-ee9c29479f11';
|
||||
$productId = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
|
||||
@@ -635,13 +597,11 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the image action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController::image
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testImageGetLoggedIn(): void
|
||||
{
|
||||
public function testImageGetLoggedIn(): void {
|
||||
$id = '2c386086-f4c5-4093-bea5-ee9c29479f58';
|
||||
// $this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -653,4 +613,5 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,33 +3,28 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\ORM\Table;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Controller\ProductSkusController;
|
||||
use CakeProducts\Model\Table\ProductSkusTable;
|
||||
use CakeProducts\Model\Table\ProductSkuVariantValuesTable;
|
||||
use CakeProducts\Model\Table\ProductsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductSkusController Test Case
|
||||
*/
|
||||
#[CoversClass(ProductSkusController::class)]
|
||||
class ProductSkusControllerTest extends BaseControllerTest
|
||||
{
|
||||
class ProductSkusControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject table
|
||||
*
|
||||
* @var ProductSkusTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductSkusTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ProductSkus;
|
||||
|
||||
/**
|
||||
* Test subject table
|
||||
*
|
||||
* @var ProductSkuVariantValuesTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductSkuVariantValuesTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ProductSkuVariantValues;
|
||||
|
||||
@@ -53,8 +48,7 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
@@ -72,8 +66,7 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductSkus);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -85,12 +78,11 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductSkusController::index()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGet(): void
|
||||
{
|
||||
public function testIndexGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -107,12 +99,11 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductSkusController::view()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGet(): void
|
||||
{
|
||||
public function testViewGet(): void {
|
||||
$id = '3a477e3e-7977-4813-81f6-f85949613979';
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -131,12 +122,11 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductSkusController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void
|
||||
{
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->ProductSkus->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -144,7 +134,7 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductSkus',
|
||||
'action' => 'add',
|
||||
'cfc98a9a-29b2-44c8-b587-8156adc05317'
|
||||
'cfc98a9a-29b2-44c8-b587-8156adc05317',
|
||||
];
|
||||
$this->get($url);
|
||||
$this->assertResponseCode(200);
|
||||
@@ -159,12 +149,11 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductSkusController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostSuccess(): void
|
||||
{
|
||||
public function testAddPostSuccess(): void {
|
||||
$cntBefore = $this->ProductSkus->find()->count();
|
||||
$cntVariantValuesBefore = $this->ProductSkuVariantValues->find()->count();
|
||||
|
||||
@@ -205,12 +194,11 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductSkusController::add()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostFailure(): void
|
||||
{
|
||||
public function testAddPostFailure(): void {
|
||||
$cntBefore = $this->ProductSkus->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -241,12 +229,11 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
* Tests the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductSkusController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGet(): void
|
||||
{
|
||||
public function testEditGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -264,12 +251,11 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductSkusController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutSuccess(): void
|
||||
{
|
||||
public function testEditPutSuccess(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '3a477e3e-7977-4813-81f6-f85949613979';
|
||||
$before = $this->ProductSkus->get($id);
|
||||
@@ -297,12 +283,11 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductSkusController::edit()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutFailure(): void
|
||||
{
|
||||
public function testEditPutFailure(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = '3a477e3e-7977-4813-81f6-f85949613979';
|
||||
$before = $this->ProductSkus->get($id);
|
||||
@@ -332,12 +317,11 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductSkusController::delete()
|
||||
* @throws Exception
|
||||
* @throws \PHPUnit\Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
public function testDelete(): void {
|
||||
$cntBefore = $this->ProductSkus->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -354,4 +338,5 @@ class ProductSkusControllerTest extends BaseControllerTest
|
||||
$cntAfter = $this->ProductSkus->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,25 +3,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\ORM\Table;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Controller\ProductsController;
|
||||
use CakeProducts\Model\Table\ProductCatalogsTable;
|
||||
use CakeProducts\Model\Table\ProductsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductsController Test Case
|
||||
*/
|
||||
#[CoversClass(ProductsController::class)]
|
||||
class ProductsControllerTest extends BaseControllerTest
|
||||
{
|
||||
class ProductsControllerTest extends BaseControllerTest {
|
||||
|
||||
/**
|
||||
* Test subject table
|
||||
*
|
||||
* @var ProductsTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductsTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $Products;
|
||||
|
||||
@@ -44,8 +39,7 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
@@ -58,8 +52,7 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->Products);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -70,13 +63,11 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the index action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductsController::index
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testIndexGet(): void
|
||||
{
|
||||
public function testIndexGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -92,13 +83,11 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the view action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductsController::view
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testViewGet(): void
|
||||
{
|
||||
public function testViewGet(): void {
|
||||
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -116,13 +105,11 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductsController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddGet(): void
|
||||
{
|
||||
public function testAddGet(): void {
|
||||
$cntBefore = $this->Products->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -143,13 +130,11 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductsController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostSuccess(): void
|
||||
{
|
||||
public function testAddPostSuccess(): void {
|
||||
$cntBefore = $this->Products->find()->count();
|
||||
$productAttributesCntBefore = $this->Products->ProductAttributes->find()->count();
|
||||
|
||||
@@ -183,19 +168,16 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
$this->assertEquals($productAttributesCntBefore + 1, $productAttributesCntAfter);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test add method
|
||||
*
|
||||
* Tests a POST request to the add action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductsController::add
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testAddPostFailure(): void
|
||||
{
|
||||
public function testAddPostFailure(): void {
|
||||
$cntBefore = $this->Products->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -223,13 +205,11 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductsController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditGet(): void
|
||||
{
|
||||
public function testEditGet(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -246,13 +226,11 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductsController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutSuccess(): void
|
||||
{
|
||||
public function testEditPutSuccess(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
|
||||
$before = $this->Products->get($id);
|
||||
@@ -284,13 +262,11 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
*
|
||||
* Tests a PUT request to the edit action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductsController::edit
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testEditPutFailure(): void
|
||||
{
|
||||
public function testEditPutFailure(): void {
|
||||
$this->loginUserByRole('admin');
|
||||
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
|
||||
$before = $this->Products->get($id);
|
||||
@@ -318,14 +294,12 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
* Test delete method
|
||||
*
|
||||
* Tests the delete action with a logged in user
|
||||
*
|
||||
* @return void
|
||||
*@throws Exception
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductsController::delete
|
||||
*@throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
public function testDelete(): void {
|
||||
$cntBefore = $this->Products->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
@@ -342,4 +316,5 @@ class ProductsControllerTest extends BaseControllerTest
|
||||
$cntAfter = $this->Products->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Model\Table;
|
||||
|
||||
use Cake\ORM\Table;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ExternalProductCatalogsTable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
@@ -12,12 +11,12 @@ use PHPUnit\Framework\Attributes\CoversClass;
|
||||
* CakeProducts\Model\Table\ExternalProductCatalogsTable Test Case
|
||||
*/
|
||||
#[CoversClass(ExternalProductCatalogsTable::class)]
|
||||
class ExternalProductCatalogsTableTest extends TestCase
|
||||
{
|
||||
class ExternalProductCatalogsTableTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var ExternalProductCatalogsTable
|
||||
* @var \CakeProducts\Model\Table\ExternalProductCatalogsTable
|
||||
*/
|
||||
protected $ExternalProductCatalogs;
|
||||
|
||||
@@ -37,8 +36,7 @@ class ExternalProductCatalogsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('ExternalProductCatalogs') ? [] : ['className' => ExternalProductCatalogsTable::class];
|
||||
$this->ExternalProductCatalogs = $this->getTableLocator()->get('ExternalProductCatalogs', $config);
|
||||
@@ -49,8 +47,7 @@ class ExternalProductCatalogsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ExternalProductCatalogs);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -59,11 +56,10 @@ class ExternalProductCatalogsTableTest extends TestCase
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::initialize
|
||||
* @return void
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
public function testInitialize(): void {
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'ProductCatalogs',
|
||||
@@ -92,22 +88,21 @@ class ExternalProductCatalogsTableTest extends TestCase
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::validationDefault
|
||||
* @return void
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
public function testValidationDefault(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::buildRules
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
public function testBuildRules(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Model\Table;
|
||||
|
||||
use Cake\ORM\Table;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ProductCatalogsTable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
@@ -12,12 +11,12 @@ use PHPUnit\Framework\Attributes\CoversClass;
|
||||
* CakeProducts\Model\Table\ProductCatalogsTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCatalogsTable::class)]
|
||||
class ProductCatalogsTableTest extends TestCase
|
||||
{
|
||||
class ProductCatalogsTableTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var ProductCatalogsTable|Table
|
||||
* @var \CakeProducts\Model\Table\ProductCatalogsTable|\Cake\ORM\Table
|
||||
*/
|
||||
protected $ProductCatalogs;
|
||||
|
||||
@@ -37,8 +36,7 @@ class ProductCatalogsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('ProductCatalogs') ? [] : ['className' => ProductCatalogsTable::class];
|
||||
$this->ProductCatalogs = $this->getTableLocator()->get('ProductCatalogs', $config);
|
||||
@@ -49,8 +47,7 @@ class ProductCatalogsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductCatalogs);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -59,11 +56,10 @@ class ProductCatalogsTableTest extends TestCase
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCatalogsTable::initialize
|
||||
* @return void
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
public function testInitialize(): void {
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'ProductCategories',
|
||||
@@ -91,11 +87,11 @@ class ProductCatalogsTableTest extends TestCase
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCatalogsTable::validationDefault
|
||||
* @return void
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
public function testValidationDefault(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ use PHPUnit\Framework\Attributes\CoversClass;
|
||||
* CakeProducts\Model\Table\ProductCategoriesTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoriesTable::class)]
|
||||
class ProductCategoriesTableTest extends TestCase
|
||||
{
|
||||
class ProductCategoriesTableTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
@@ -35,8 +35,7 @@ class ProductCategoriesTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('ProductCategories') ? [] : ['className' => ProductCategoriesTable::class];
|
||||
$this->ProductCategories = $this->getTableLocator()->get('ProductCategories', $config);
|
||||
@@ -47,8 +46,7 @@ class ProductCategoriesTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductCategories);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -57,11 +55,10 @@ class ProductCategoriesTableTest extends TestCase
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoriesTable::initialize()
|
||||
* @return void
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
public function testInitialize(): void {
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'ProductCatalogs',
|
||||
@@ -96,22 +93,21 @@ class ProductCategoriesTableTest extends TestCase
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoriesTable::validationDefault()
|
||||
* @return void
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
public function testValidationDefault(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoriesTable::buildRules()
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
public function testBuildRules(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ use PHPUnit\Framework\Attributes\CoversClass;
|
||||
* CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoryAttributeOptionsTable::class)]
|
||||
class ProductCategoryAttributeOptionsTableTest extends TestCase
|
||||
{
|
||||
class ProductCategoryAttributeOptionsTableTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var ProductCategoryAttributeOptionsTable
|
||||
* @var \CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable
|
||||
*/
|
||||
protected $ProductCategoryAttributeOptions;
|
||||
|
||||
@@ -34,8 +34,7 @@ class ProductCategoryAttributeOptionsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('ProductCategoryAttributeOptions') ? [] : ['className' => ProductCategoryAttributeOptionsTable::class];
|
||||
$this->ProductCategoryAttributeOptions = $this->getTableLocator()->get('ProductCategoryAttributeOptions', $config);
|
||||
@@ -46,8 +45,7 @@ class ProductCategoryAttributeOptionsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductCategoryAttributeOptions);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -56,11 +54,10 @@ class ProductCategoryAttributeOptionsTableTest extends TestCase
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable::initialize
|
||||
* @return void
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
public function testInitialize(): void {
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'ProductCategoryAttributes',
|
||||
@@ -87,22 +84,21 @@ class ProductCategoryAttributeOptionsTableTest extends TestCase
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable::validationDefault
|
||||
* @return void
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
public function testValidationDefault(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable::buildRules
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
public function testBuildRules(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ use PHPUnit\Framework\Attributes\CoversClass;
|
||||
* CakeProducts\Model\Table\ProductCategoryAttributesTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoryAttributesTable::class)]
|
||||
class ProductCategoryAttributesTableTest extends TestCase
|
||||
{
|
||||
class ProductCategoryAttributesTableTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var ProductCategoryAttributesTable
|
||||
* @var \CakeProducts\Model\Table\ProductCategoryAttributesTable
|
||||
*/
|
||||
protected $ProductCategoryAttributes;
|
||||
|
||||
@@ -36,8 +36,7 @@ class ProductCategoryAttributesTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('ProductCategoryAttributes') ? [] : ['className' => ProductCategoryAttributesTable::class];
|
||||
$this->ProductCategoryAttributes = $this->getTableLocator()->get('ProductCategoryAttributes', $config);
|
||||
@@ -48,8 +47,7 @@ class ProductCategoryAttributesTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductCategoryAttributes);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -58,11 +56,10 @@ class ProductCategoryAttributesTableTest extends TestCase
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoryAttributesTable::initialize
|
||||
* @return void
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
public function testInitialize(): void {
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'ProductCategories',
|
||||
@@ -90,22 +87,21 @@ class ProductCategoryAttributesTableTest extends TestCase
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoryAttributesTable::validationDefault
|
||||
* @return void
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
public function testValidationDefault(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoryAttributesTable::buildRules
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
public function testBuildRules(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,16 +3,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Model\Table;
|
||||
|
||||
use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* App\Model\Table\ProductCategoryVariantOptionsTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoryVariantOptionsTable::class)]
|
||||
class ProductCategoryVariantOptionsTableTest extends TestCase
|
||||
{
|
||||
class ProductCategoryVariantOptionsTableTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
@@ -35,8 +35,7 @@ class ProductCategoryVariantOptionsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('ProductCategoryVariantOptions') ? [] : ['className' => ProductCategoryVariantOptionsTable::class];
|
||||
$this->ProductCategoryVariantOptions = $this->getTableLocator()->get('ProductCategoryVariantOptions', $config);
|
||||
@@ -47,8 +46,7 @@ class ProductCategoryVariantOptionsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductCategoryVariantOptions);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -57,11 +55,10 @@ class ProductCategoryVariantOptionsTableTest extends TestCase
|
||||
/**
|
||||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoryVariantOptionsTable::initialize()
|
||||
* @return void
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
public function testInitialize(): void {
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'ProductCategoryVariants',
|
||||
@@ -88,22 +85,21 @@ class ProductCategoryVariantOptionsTableTest extends TestCase
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoryVariantOptionsTable::validationDefault()
|
||||
* @return void
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
public function testValidationDefault(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeProducts\Model\Table\ProductCategoryVariantOptionsTable::buildRules()
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
public function testBuildRules(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Test\TestCase\Model\Table;
|
||||
|
||||
use CakeProducts\Model\Table\ProductVariantsTable;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ProductVariantsTable;
|
||||
|
||||
/**
|
||||
* CakeProducts\Model\Table\ProductVariantsTable Test Case
|
||||
*/
|
||||
class ProductVariantsTableTest extends TestCase
|
||||
{
|
||||
class ProductVariantsTableTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
@@ -34,8 +34,7 @@ class ProductVariantsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('ProductVariants') ? [] : ['className' => ProductVariantsTable::class];
|
||||
$this->ProductVariants = $this->getTableLocator()->get('ProductVariants', $config);
|
||||
@@ -46,8 +45,7 @@ class ProductVariantsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
protected function tearDown(): void {
|
||||
unset($this->ProductVariants);
|
||||
|
||||
parent::tearDown();
|
||||
@@ -58,8 +56,7 @@ class ProductVariantsTableTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
public function testInitialize(): void {
|
||||
// verify all associations loaded
|
||||
$expectedAssociations = [
|
||||
'Products',
|
||||
@@ -86,22 +83,21 @@ class ProductVariantsTableTest extends TestCase
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \App\Model\Table\ProductVariantsTable::validationDefault()
|
||||
* @return void
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
public function testValidationDefault(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \App\Model\Table\ProductVariantsTable::buildRules()
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
public function testBuildRules(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user