add soft delete via muffin/trash to all product related tables
This commit is contained in:
@@ -23,7 +23,7 @@ class ExternalProductCatalogsFixture extends TestFixture
|
||||
'base_url' => 'http://localhost:8766',
|
||||
'api_url' => 'http://localhost:8766/api',
|
||||
'created' => '2024-11-22 09:39:37',
|
||||
'deleted' => '2024-11-22 09:39:37',
|
||||
'deleted' => null,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
|
||||
@@ -19,10 +19,12 @@ class ExternalProductCatalogsProductCatalogsFixture extends TestFixture
|
||||
{
|
||||
$this->records = [
|
||||
[
|
||||
'id' => 1,
|
||||
'external_product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205769999',
|
||||
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
|
||||
'created' => '2024-11-22 09:39:37',
|
||||
'enabled' => false,
|
||||
'deleted' => null,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
|
||||
@@ -23,12 +23,14 @@ class ProductCatalogsFixture extends TestFixture
|
||||
'name' => 'Automotive',
|
||||
'catalog_description' => '',
|
||||
'enabled' => true,
|
||||
'deleted' => null,
|
||||
],
|
||||
[
|
||||
'id' => 'f56f3412-ed23-490b-be6e-016208c415d2',
|
||||
'name' => 'Software',
|
||||
'catalog_description' => '',
|
||||
'enabled' => true,
|
||||
'deleted' => null,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
|
||||
@@ -28,6 +28,7 @@ class ProductCategoriesFixture extends TestFixture
|
||||
'lft' => 1,
|
||||
'rght' => 4,
|
||||
'enabled' => true,
|
||||
'deleted' => null,
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
@@ -39,6 +40,7 @@ class ProductCategoriesFixture extends TestFixture
|
||||
'lft' => 2,
|
||||
'rght' => 3,
|
||||
'enabled' => true,
|
||||
'deleted' => null,
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
@@ -50,6 +52,7 @@ class ProductCategoriesFixture extends TestFixture
|
||||
'lft' => 5,
|
||||
'rght' => 8,
|
||||
'enabled' => true,
|
||||
'deleted' => null,
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
@@ -61,6 +64,7 @@ class ProductCategoriesFixture extends TestFixture
|
||||
'lft' => 6,
|
||||
'rght' => 7,
|
||||
'enabled' => true,
|
||||
'deleted' => null,
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
@@ -72,6 +76,7 @@ class ProductCategoriesFixture extends TestFixture
|
||||
'lft' => 9,
|
||||
'rght' => 12,
|
||||
'enabled' => true,
|
||||
'deleted' => null,
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
@@ -83,6 +88,7 @@ class ProductCategoriesFixture extends TestFixture
|
||||
'lft' => 10,
|
||||
'rght' => 11,
|
||||
'enabled' => true,
|
||||
'deleted' => null,
|
||||
],
|
||||
[
|
||||
'id' => 7,
|
||||
@@ -94,6 +100,7 @@ class ProductCategoriesFixture extends TestFixture
|
||||
'lft' => 1,
|
||||
'rght' => 2,
|
||||
'enabled' => true,
|
||||
'deleted' => null,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
|
||||
@@ -24,6 +24,7 @@ class ProductCategoryAttributeOptionsFixture extends TestFixture
|
||||
'attribute_value' => 'Red',
|
||||
'attribute_label' => 'Red',
|
||||
'enabled' => 1,
|
||||
'deleted' => null,
|
||||
],
|
||||
[
|
||||
'id' => 'e06f1723-2456-483a-b3c4-004603e032a1',
|
||||
@@ -31,6 +32,7 @@ class ProductCategoryAttributeOptionsFixture extends TestFixture
|
||||
'attribute_value' => 'Blue',
|
||||
'attribute_label' => 'Blue',
|
||||
'enabled' => 1,
|
||||
'deleted' => null,
|
||||
],
|
||||
[
|
||||
'id' => 'e06f1723-2456-483a-b3c4-004603e032a2',
|
||||
@@ -38,6 +40,7 @@ class ProductCategoryAttributeOptionsFixture extends TestFixture
|
||||
'attribute_value' => 'Green',
|
||||
'attribute_label' => 'Green',
|
||||
'enabled' => 1,
|
||||
'deleted' => null,
|
||||
]
|
||||
];
|
||||
parent::init();
|
||||
|
||||
@@ -24,6 +24,7 @@ class ProductCategoryAttributesFixture extends TestFixture
|
||||
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
|
||||
'attribute_type_id' => 1,
|
||||
'enabled' => 1,
|
||||
'deleted' => null,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
|
||||
@@ -23,6 +23,7 @@ class ProductsFixture extends TestFixture
|
||||
'name' => '12AWG RED TXL Wire',
|
||||
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
|
||||
'product_type_id' => 1,
|
||||
'deleted' => null,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
|
||||
@@ -45,7 +45,7 @@ class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControlle
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
$this->disableErrorHandlerMiddleware();
|
||||
$this->ExternalProductCatalogsProductCatalogs = $this->getTableLocator()->get('ExternalProductCatalogsProductCatalogs');
|
||||
$this->ExternalProductCatalogsProductCatalogs = $this->getTableLocator()->get('CakeProducts.ExternalProductCatalogsProductCatalogs');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,6 +99,7 @@ class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControlle
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
$cntBeforeWithTrashed = $this->ExternalProductCatalogsProductCatalogs->find('withTrashed')->count();
|
||||
$cntBefore = $this->ExternalProductCatalogsProductCatalogs->find()->count();
|
||||
|
||||
// $this->loginUserByRole('admin');
|
||||
@@ -112,7 +113,9 @@ class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControlle
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('external-product-catalogs');
|
||||
|
||||
$cntAfterWithTrashed = $this->ExternalProductCatalogsProductCatalogs->find('withTrashed')->count();
|
||||
$cntAfter = $this->ExternalProductCatalogsProductCatalogs->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
$this->assertEquals($cntBeforeWithTrashed, $cntAfterWithTrashed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
// $this->enableCsrfToken();
|
||||
// $this->enableSecurityToken();
|
||||
$this->disableErrorHandlerMiddleware();
|
||||
$this->ProductCategories = $this->getTableLocator()->get('ProductCategories');
|
||||
$this->ProductCategories = $this->getTableLocator()->get('CakeProducts.ProductCategories');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,7 +315,7 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
public function testDelete(): void
|
||||
{
|
||||
$cntBefore = $this->ProductCategories->find()->count();
|
||||
|
||||
$cntBeforeWithTrashed = $this->ProductCategories->find('withTrashed')->count();
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
'plugin' => 'CakeProducts',
|
||||
@@ -328,6 +328,9 @@ class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
$this->assertRedirectContains('product-categories');
|
||||
|
||||
$cntAfter = $this->ProductCategories->find()->count();
|
||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||
$cntAfterWithTrashed = $this->ProductCategories->find('withTrashed')->count();
|
||||
|
||||
$this->assertEquals($cntBefore - 2, $cntAfter); // has 1 child category
|
||||
$this->assertEquals($cntBeforeWithTrashed, $cntAfterWithTrashed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ class ExternalProductCatalogsTableTest extends TestCase
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [
|
||||
'Timestamp',
|
||||
'Trash',
|
||||
];
|
||||
$behaviors = $this->ExternalProductCatalogs->behaviors();
|
||||
|
||||
|
||||
@@ -75,7 +75,9 @@ class ProductCatalogsTableTest extends TestCase
|
||||
}
|
||||
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [];
|
||||
$expectedBehaviors = [
|
||||
'Trash',
|
||||
];
|
||||
$behaviors = $this->ProductCatalogs->behaviors();
|
||||
|
||||
$this->assertCount(count($expectedBehaviors), $behaviors);
|
||||
|
||||
@@ -78,6 +78,7 @@ class ProductCategoriesTableTest extends TestCase
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [
|
||||
'Tree',
|
||||
'Trash',
|
||||
];
|
||||
$behaviors = $this->ProductCategories->behaviors();
|
||||
|
||||
|
||||
@@ -71,7 +71,9 @@ class ProductCategoryAttributeOptionsTableTest extends TestCase
|
||||
}
|
||||
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [];
|
||||
$expectedBehaviors = [
|
||||
'Trash',
|
||||
];
|
||||
$behaviors = $this->ProductCategoryAttributeOptions->behaviors();
|
||||
|
||||
$this->assertCount(count($expectedBehaviors), $behaviors);
|
||||
|
||||
@@ -74,7 +74,9 @@ class ProductCategoryAttributesTableTest extends TestCase
|
||||
}
|
||||
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [];
|
||||
$expectedBehaviors = [
|
||||
'Trash',
|
||||
];
|
||||
$behaviors = $this->ProductCategoryAttributes->behaviors();
|
||||
|
||||
$this->assertCount(count($expectedBehaviors), $behaviors);
|
||||
|
||||
@@ -73,7 +73,9 @@ class ProductsTableTest extends TestCase
|
||||
}
|
||||
|
||||
// verify all behaviors loaded
|
||||
$expectedBehaviors = [];
|
||||
$expectedBehaviors = [
|
||||
'Trash',
|
||||
];
|
||||
$behaviors = $this->Products->behaviors();
|
||||
|
||||
$this->assertCount(count($expectedBehaviors), $behaviors);
|
||||
|
||||
Reference in New Issue
Block a user