add soft delete via muffin/trash to all product related tables
This commit is contained in:
@@ -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