variant options coming along - add test passing
This commit is contained in:
@@ -6,6 +6,7 @@ namespace CakeProducts\Test\TestCase\Controller;
|
||||
use CakeProducts\Controller\ProductCategoryVariantsController;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable;
|
||||
use CakeProducts\Model\Table\ProductCategoryVariantsTable;
|
||||
use PHPUnit\Exception;
|
||||
|
||||
@@ -22,6 +23,13 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
* @var ProductCategoryVariantsTable|Table
|
||||
*/
|
||||
protected $ProductCategoryVariants;
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var ProductCategoryVariantOptionsTable|Table
|
||||
*/
|
||||
protected $ProductCategoryVariantOptions;
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
@@ -42,6 +50,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
{
|
||||
parent::setUp();
|
||||
$this->ProductCategoryVariants = $this->getTableLocator()->get('ProductCategoryVariants');
|
||||
$this->ProductCategoryVariantOptions = $this->getTableLocator()->get('ProductCategoryVariantOptions');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,6 +61,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->ProductCategoryVariants);
|
||||
unset($this->ProductCategoryVariantOptions);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
@@ -142,6 +152,7 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
public function testAddPostLoggedInSuccess(): void
|
||||
{
|
||||
$cntBefore = $this->ProductCategoryVariants->find()->count();
|
||||
$cntBeforeOptions = $this->ProductCategoryVariantOptions->find()->count();
|
||||
|
||||
$this->loginUserByRole('admin');
|
||||
$url = [
|
||||
@@ -152,14 +163,29 @@ class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
$data = [
|
||||
'name' => 'Size',
|
||||
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
|
||||
'product_id' => '',
|
||||
'enabled' => true,
|
||||
'product_category_variant_options' => [
|
||||
[
|
||||
'variant_value' => 'XL',
|
||||
'variant_label' => 'XL',
|
||||
'enabled' => true,
|
||||
],
|
||||
[
|
||||
'variant_value' => 'XXL',
|
||||
'variant_label' => 'XXL',
|
||||
'enabled' => true,
|
||||
],
|
||||
]
|
||||
];
|
||||
$this->post($url, $data);
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('product-category-variants');
|
||||
|
||||
$cntAfter = $this->ProductCategoryVariants->find()->count();
|
||||
$cntAfterOptions = $this->ProductCategoryVariantOptions->find()->count();
|
||||
$this->assertEquals($cntBefore + 1, $cntAfter);
|
||||
$this->assertEquals($cntBeforeOptions + 2, $cntAfterOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,8 +24,8 @@ class ProductCategoryVariantOptionsTableTest extends TestCase
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
// 'ProductCategoryVariantOptions',
|
||||
// 'ProductCategoryVariants',
|
||||
'plugin.CakeProducts.ProductCategoryVariants',
|
||||
'plugin.CakeProducts.ProductCategoryVariantOptions',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user