composer update + load more dev dependencies for code quality, checkstyle fix

This commit is contained in:
bs
2026-08-21 23:57:55 -07:00
parent c196dc2fe0
commit 8e142f56ab
104 changed files with 6341 additions and 6743 deletions
@@ -8,24 +8,24 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ExternalProductCatalogsFixture
*/
class ExternalProductCatalogsFixture extends TestFixture
{
/**
class ExternalProductCatalogsFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '115153f3-2f59-4234-8ff8-e1b205769999',
'base_url' => 'http://localhost:8766',
'api_url' => 'http://localhost:8766/api',
'created' => '2024-11-22 09:39:37',
'deleted' => null,
],
];
parent::init();
}
public function init(): void {
$this->records = [
[
'id' => '115153f3-2f59-4234-8ff8-e1b205769999',
'base_url' => 'http://localhost:8766',
'api_url' => 'http://localhost:8766/api',
'created' => '2024-11-22 09:39:37',
'deleted' => null,
],
];
parent::init();
}
}
@@ -8,25 +8,25 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ExternalProductCatalogsProductCatalogsFixture
*/
class ExternalProductCatalogsProductCatalogsFixture extends TestFixture
{
/**
class ExternalProductCatalogsProductCatalogsFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$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();
}
public function init(): void {
$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();
}
}
+7 -9
View File
@@ -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();
}
];
parent::init();
}
}
+23 -23
View File
@@ -8,31 +8,31 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductCatalogsFixture
*/
class ProductCatalogsFixture extends TestFixture
{
/**
class ProductCatalogsFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'name' => 'Automotive',
'catalog_description' => '',
'enabled' => true,
'deleted' => null,
],
[
'id' => 'f56f3412-ed23-490b-be6e-016208c415d2',
'name' => 'Software',
'catalog_description' => '',
'enabled' => true,
'deleted' => null,
],
];
parent::init();
}
public function init(): void {
$this->records = [
[
'id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'name' => 'Automotive',
'catalog_description' => '',
'enabled' => true,
'deleted' => null,
],
[
'id' => 'f56f3412-ed23-490b-be6e-016208c415d2',
'name' => 'Software',
'catalog_description' => '',
'enabled' => true,
'deleted' => null,
],
];
parent::init();
}
}
+93 -93
View File
@@ -8,101 +8,101 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductCategoriesFixture
*/
class ProductCategoriesFixture extends TestFixture
{
/**
class ProductCategoriesFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => 1,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'name' => 'Engine',
'category_description' => '',
'parent_id' => null,
'lft' => 1,
'rght' => 4,
'enabled' => true,
'deleted' => null,
],
[
'id' => 2,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => '3c2377c5-b97c-4bc9-9660-8f77b4893d8b',
'name' => 'Engine Internals',
'category_description' => '',
'parent_id' => 1,
'lft' => 2,
'rght' => 3,
'enabled' => true,
'deleted' => null,
],
[
'id' => 3,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => 'fbee6709-396f-4bb4-b60b-e125b0bc4e83',
'name' => 'Electrical',
'category_description' => '',
'parent_id' => null,
'lft' => 5,
'rght' => 8,
'enabled' => true,
'deleted' => null,
],
[
'id' => 4,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'name' => 'Wiring',
'category_description' => '',
'parent_id' => 3,
'lft' => 6,
'rght' => 7,
'enabled' => true,
'deleted' => null,
],
[
'id' => 5,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => 'c447b6f4-0fb1-4d59-ba45-5613829a725a',
'name' => 'Suspension',
'category_description' => '',
'parent_id' => null,
'lft' => 9,
'rght' => 12,
'enabled' => true,
'deleted' => null,
],
[
'id' => 6,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => '1e749d3b-aee0-48a5-8d6c-8cf2b83e9b6e',
'name' => 'Coilovers',
'category_description' => '',
'parent_id' => 5,
'lft' => 10,
'rght' => 11,
'enabled' => true,
'deleted' => null,
],
[
'id' => 7,
'product_catalog_id' => 'f56f3412-ed23-490b-be6e-016208c415d2',
'internal_id' => '8c89a3ca-d56f-46bf-a738-7e85b3342b2a',
'name' => 'Support',
'category_description' => '',
'parent_id' => null,
'lft' => 1,
'rght' => 2,
'enabled' => true,
'deleted' => null,
],
];
parent::init();
}
public function init(): void {
$this->records = [
[
'id' => 1,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'name' => 'Engine',
'category_description' => '',
'parent_id' => null,
'lft' => 1,
'rght' => 4,
'enabled' => true,
'deleted' => null,
],
[
'id' => 2,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => '3c2377c5-b97c-4bc9-9660-8f77b4893d8b',
'name' => 'Engine Internals',
'category_description' => '',
'parent_id' => 1,
'lft' => 2,
'rght' => 3,
'enabled' => true,
'deleted' => null,
],
[
'id' => 3,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => 'fbee6709-396f-4bb4-b60b-e125b0bc4e83',
'name' => 'Electrical',
'category_description' => '',
'parent_id' => null,
'lft' => 5,
'rght' => 8,
'enabled' => true,
'deleted' => null,
],
[
'id' => 4,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'name' => 'Wiring',
'category_description' => '',
'parent_id' => 3,
'lft' => 6,
'rght' => 7,
'enabled' => true,
'deleted' => null,
],
[
'id' => 5,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => 'c447b6f4-0fb1-4d59-ba45-5613829a725a',
'name' => 'Suspension',
'category_description' => '',
'parent_id' => null,
'lft' => 9,
'rght' => 12,
'enabled' => true,
'deleted' => null,
],
[
'id' => 6,
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'internal_id' => '1e749d3b-aee0-48a5-8d6c-8cf2b83e9b6e',
'name' => 'Coilovers',
'category_description' => '',
'parent_id' => 5,
'lft' => 10,
'rght' => 11,
'enabled' => true,
'deleted' => null,
],
[
'id' => 7,
'product_catalog_id' => 'f56f3412-ed23-490b-be6e-016208c415d2',
'internal_id' => '8c89a3ca-d56f-46bf-a738-7e85b3342b2a',
'name' => 'Support',
'category_description' => '',
'parent_id' => null,
'lft' => 1,
'rght' => 2,
'enabled' => true,
'deleted' => null,
],
];
parent::init();
}
}
@@ -8,41 +8,41 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductCategoryAttributeOptionsFixture
*/
class ProductCategoryAttributeOptionsFixture extends TestFixture
{
/**
class ProductCategoryAttributeOptionsFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => 'e06f1723-2456-483a-b3c4-004603e032a8',
'product_category_attribute_id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
'attribute_value' => 'Red',
'attribute_label' => 'Red',
'enabled' => 1,
'deleted' => null,
],
[
'id' => 'e06f1723-2456-483a-b3c4-004603e032a1',
'product_category_attribute_id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
'attribute_value' => 'Blue',
'attribute_label' => 'Blue',
'enabled' => 1,
'deleted' => null,
],
[
'id' => 'e06f1723-2456-483a-b3c4-004603e032a2',
'product_category_attribute_id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
'attribute_value' => 'Green',
'attribute_label' => 'Green',
'enabled' => 1,
'deleted' => null,
]
];
parent::init();
}
public function init(): void {
$this->records = [
[
'id' => 'e06f1723-2456-483a-b3c4-004603e032a8',
'product_category_attribute_id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
'attribute_value' => 'Red',
'attribute_label' => 'Red',
'enabled' => 1,
'deleted' => null,
],
[
'id' => 'e06f1723-2456-483a-b3c4-004603e032a1',
'product_category_attribute_id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
'attribute_value' => 'Blue',
'attribute_label' => 'Blue',
'enabled' => 1,
'deleted' => null,
],
[
'id' => 'e06f1723-2456-483a-b3c4-004603e032a2',
'product_category_attribute_id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
'attribute_value' => 'Green',
'attribute_label' => 'Green',
'enabled' => 1,
'deleted' => null,
],
];
parent::init();
}
}
@@ -8,25 +8,25 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductCategoryAttributesFixture
*/
class ProductCategoryAttributesFixture extends TestFixture
{
/**
class ProductCategoryAttributesFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
'name' => 'Color',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'attribute_type_id' => 1,
'enabled' => 1,
'deleted' => null,
],
];
parent::init();
}
public function init(): void {
$this->records = [
[
'id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
'name' => 'Color',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'attribute_type_id' => 1,
'enabled' => 1,
'deleted' => null,
],
];
parent::init();
}
}
@@ -8,92 +8,91 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductCategoryVariantsFixture
*/
class ProductCategoryVariantOptionsFixture extends TestFixture
{
/**
class ProductCategoryVariantOptionsFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d23',
'variant_value' => 'Blue',
'variant_label' => null,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d24',
'variant_value' => 'Red',
'variant_label' => null,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
public function init(): void {
$this->records = [
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d23',
'variant_value' => 'Blue',
'variant_label' => null,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d24',
'variant_value' => 'Red',
'variant_label' => null,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d21',
'variant_value' => '12AWG',
'variant_label' => null,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d22',
'variant_value' => '14AWG',
'variant_label' => null,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d21',
'variant_value' => '12AWG',
'variant_label' => null,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d22',
'variant_value' => '14AWG',
'variant_label' => null,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78111',
'variant_value' => 'Months',
'variant_label' => 'Months',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78111',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78112',
'variant_value' => 'Years',
'variant_label' => 'Years',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78111',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f22221',
'variant_value' => '6',
'variant_label' => '6',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78222',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f22222',
'variant_value' => 12,
'variant_label' => 12,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78222',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
];
parent::init();
}
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78111',
'variant_value' => 'Months',
'variant_label' => 'Months',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78111',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78112',
'variant_value' => 'Years',
'variant_label' => 'Years',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78111',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f22221',
'variant_value' => '6',
'variant_label' => '6',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78222',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f22222',
'variant_value' => 12,
'variant_label' => 12,
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78222',
'created' => '2025-07-04 12:00:00',
'modified' => '2025-07-04 12:00:00',
'enabled' => 1,
],
];
parent::init();
}
}
@@ -8,46 +8,46 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductCategoryVariantsFixture
*/
class ProductCategoryVariantsFixture extends TestFixture
{
/**
class ProductCategoryVariantsFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78111',
'name' => 'Subscription Length Units',
'product_category_id' => null,
'enabled' => true,
'is_system_variant' => true,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78222',
'name' => 'Subscription Length',
'product_category_id' => null,
'enabled' => true,
'is_system_variant' => true,
],
public function init(): void {
$this->records = [
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78111',
'name' => 'Subscription Length Units',
'product_category_id' => null,
'enabled' => true,
'is_system_variant' => true,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78222',
'name' => 'Subscription Length',
'product_category_id' => null,
'enabled' => true,
'is_system_variant' => true,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'name' => 'Color',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'enabled' => true,
'is_system_variant' => false,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'name' => 'AWG',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'enabled' => true,
'is_system_variant' => false,
],
];
parent::init();
}
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'name' => 'Color',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'enabled' => true,
'is_system_variant' => false,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'name' => 'AWG',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'enabled' => true,
'is_system_variant' => false,
],
];
parent::init();
}
}
+105 -105
View File
@@ -8,116 +8,116 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductPhotosFixture
*/
class ProductPhotosFixture extends TestFixture
{
/**
class ProductPhotosFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f58',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => null,
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f58.png',
'primary_photo' => 1,
'primary_category_photo' => 0,
'primary_sku_photo' => 0,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
public function init(): void {
$this->records = [
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f58',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => null,
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f58.png',
'primary_photo' => 1,
'primary_category_photo' => 0,
'primary_sku_photo' => 0,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f51',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => null,
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'categories',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f51.png',
'primary_photo' => 0,
'primary_category_photo' => 1,
'primary_sku_photo' => 0,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f51',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => null,
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'categories',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f51.png',
'primary_photo' => 0,
'primary_category_photo' => 1,
'primary_sku_photo' => 0,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f50',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => null,
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f58.png',
'primary_photo' => 0,
'primary_category_photo' => 0,
'primary_sku_photo' => 0,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f53',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => null,
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'categories',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f51.png',
'primary_photo' => 0,
'primary_category_photo' => 0,
'primary_sku_photo' => 0,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f50',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => null,
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f58.png',
'primary_photo' => 0,
'primary_category_photo' => 0,
'primary_sku_photo' => 0,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f53',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => null,
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'categories',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f51.png',
'primary_photo' => 0,
'primary_category_photo' => 0,
'primary_sku_photo' => 0,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f11',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => '3a477e3e-7977-4813-81f6-f85949613979',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f58.png',
'primary_photo' => 0,
'primary_category_photo' => 0,
'primary_sku_photo' => 1,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f12',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => '3a477e3e-7977-4813-81f6-f85949613979',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f51.png',
'primary_photo' => 0,
'primary_category_photo' => 0,
'primary_sku_photo' => 0,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
];
parent::init();
}
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f11',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => '3a477e3e-7977-4813-81f6-f85949613979',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f58.png',
'primary_photo' => 0,
'primary_category_photo' => 0,
'primary_sku_photo' => 1,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
[
'id' => '2c386086-f4c5-4093-bea5-ee9c29479f12',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'product_sku_id' => '3a477e3e-7977-4813-81f6-f85949613979',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'photo_dir' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'photo_filename' => '2c386086-f4c5-4093-bea5-ee9c29479f51.png',
'primary_photo' => 0,
'primary_category_photo' => 0,
'primary_sku_photo' => 0,
'photo_position' => 100,
'enabled' => 1,
'created' => '2025-08-10 04:32:10',
'modified' => '2025-08-10 04:32:10',
'deleted' => null,
],
];
parent::init();
}
}
@@ -8,30 +8,30 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductSkuVariantValuesFixture
*/
class ProductSkuVariantValuesFixture extends TestFixture
{
/**
class ProductSkuVariantValuesFixture extends TestFixture {
/**
* Table name
*
* @var string
*/
public string $table = 'product_sku_variant_values';
public string $table = 'product_sku_variant_values';
/**
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '98b609d8-1d4f-484c-a13a-6adb7102da56',
'product_sku_id' => '3a477e3e-7977-4813-81f6-f85949613979',
'product_variant_id' => '2e6e4031-c430-4d07-b8d6-a4e759b72569',
'product_category_variant_option_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d23',
],
];
parent::init();
}
public function init(): void {
$this->records = [
[
'id' => '98b609d8-1d4f-484c-a13a-6adb7102da56',
'product_sku_id' => '3a477e3e-7977-4813-81f6-f85949613979',
'product_variant_id' => '2e6e4031-c430-4d07-b8d6-a4e759b72569',
'product_category_variant_option_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d23',
],
];
parent::init();
}
}
+23 -22
View File
@@ -8,34 +8,35 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductSkusFixture
*/
class ProductSkusFixture extends TestFixture
{
/**
class ProductSkusFixture extends TestFixture {
/**
* Table name
*
* @var string
*/
public string $table = 'product_skus';
/**
public string $table = 'product_skus';
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '3a477e3e-7977-4813-81f6-f85949613979',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'sku' => '3a477e3e-7977-4813-81f6-f85949613979',
'barcode' => '3a477e3e-7977-4813-81f6-f85949613979',
'price' => 1.5,
'cost' => 1.5,
'created' => '2025-04-15 09:09:15',
'modified' => '2025-04-15 09:09:15',
'deleted' => null,
],
];
parent::init();
}
public function init(): void {
$this->records = [
[
'id' => '3a477e3e-7977-4813-81f6-f85949613979',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'sku' => '3a477e3e-7977-4813-81f6-f85949613979',
'barcode' => '3a477e3e-7977-4813-81f6-f85949613979',
'price' => 1.5,
'cost' => 1.5,
'created' => '2025-04-15 09:09:15',
'modified' => '2025-04-15 09:09:15',
'deleted' => null,
],
];
parent::init();
}
}
+37 -37
View File
@@ -8,45 +8,45 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductVariantsFixture
*/
class ProductVariantsFixture extends TestFixture
{
/**
class ProductVariantsFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '2e6e4031-c430-4d07-b8d6-a4e759b72568',
'name' => 'Color',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'enabled' => 1,
],
[
'id' => '2e6e4031-c430-4d07-b8d6-a4e759b72569',
'name' => 'Color',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05318',
'enabled' => 1,
],
[
'id' => '2e6e4031-c430-4d07-b8d6-a4e759b72561',
'name' => 'AWG',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'enabled' => 1,
],
[
'id' => '2e6e4031-c430-4d07-b8d6-a4e759b72562',
'name' => 'AWG',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05318',
'enabled' => 1,
]
];
parent::init();
}
public function init(): void {
$this->records = [
[
'id' => '2e6e4031-c430-4d07-b8d6-a4e759b72568',
'name' => 'Color',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'enabled' => 1,
],
[
'id' => '2e6e4031-c430-4d07-b8d6-a4e759b72569',
'name' => 'Color',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d93',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05318',
'enabled' => 1,
],
[
'id' => '2e6e4031-c430-4d07-b8d6-a4e759b72561',
'name' => 'AWG',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'enabled' => 1,
],
[
'id' => '2e6e4031-c430-4d07-b8d6-a4e759b72562',
'name' => 'AWG',
'product_category_variant_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d94',
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05318',
'enabled' => 1,
],
];
parent::init();
}
}
+23 -23
View File
@@ -8,31 +8,31 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ProductsFixture
*/
class ProductsFixture extends TestFixture
{
/**
class ProductsFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'name' => '12AWG RED TXL Wire',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'product_type_id' => 1,
'deleted' => null,
],
[
'id' => 'cfc98a9a-29b2-44c8-b587-8156adc05318',
'name' => 'Heat Shrink',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'product_type_id' => 1,
'deleted' => null,
],
];
parent::init();
}
public function init(): void {
$this->records = [
[
'id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'name' => '12AWG RED TXL Wire',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'product_type_id' => 1,
'deleted' => null,
],
[
'id' => 'cfc98a9a-29b2-44c8-b587-8156adc05318',
'name' => 'Heat Shrink',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'product_type_id' => 1,
'deleted' => null,
],
];
parent::init();
}
}
@@ -14,55 +14,52 @@ use RecursiveIteratorIterator;
*
* Used to make logging in easier and to handle folder structure for product images
*/
class BaseControllerTest extends TestCase
{
use IntegrationTestTrait;
class BaseControllerTest extends TestCase {
public function loginUserByRole(string $role = 'admin'): void
{
$this->session(['Auth.User.id' => 1]);
$this->session(['Auth.id' => 1]);
}
use IntegrationTestTrait;
/**
public function loginUserByRole(string $role = 'admin'): void {
$this->session(['Auth.User.id' => 1]);
$this->session(['Auth.id' => 1]);
}
/**
* @return void
*/
public function testTest()
{
$this->assertEquals(1, 1);
}
public function testTest() {
$this->assertEquals(1, 1);
}
/**
/**
* setUp method
*
* @return 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';
$newName = $productsFolder . DS . '2c386086-f4c5-4093-bea5-ee9c29479f58.png';
if (file_exists($toCopy)) {
if (!file_exists($productsFolder)) {
mkdir($productsFolder, 0775, true);
}
copy($toCopy, $newName);
}
}
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';
$newName = $productsFolder . DS . '2c386086-f4c5-4093-bea5-ee9c29479f58.png';
if (file_exists($toCopy)) {
if (!file_exists($productsFolder)) {
mkdir($productsFolder, 0775, true);
}
copy($toCopy, $newName);
}
}
protected function tearDown(): void
{
parent::tearDown(); // TODO: Change the autogenerated stub
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) {
$file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath());
}
}
}
$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 ) {
$file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath());
}
}
}
}
@@ -4,332 +4,317 @@ 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;
protected $ExternalProductCatalogs;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ExternalProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ProductCatalogs',
];
protected array $fixtures = [
'plugin.CakeProducts.ExternalProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ProductCatalogs',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
protected function setUp(): void {
parent::setUp();
// $this->enableCsrfToken();
// $this->enableSecurityToken();
$this->disableErrorHandlerMiddleware();
$this->ExternalProductCatalogs = $this->getTableLocator()->get('CakeProducts.ExternalProductCatalogs');
}
$this->disableErrorHandlerMiddleware();
$this->ExternalProductCatalogs = $this->getTableLocator()->get('CakeProducts.ExternalProductCatalogs');
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ExternalProductCatalogs);
protected function tearDown(): void {
unset($this->ExternalProductCatalogs);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* Test index method
*
* 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
{
Log::debug('inside testIndexGet ExternalProductCatalogsControllerTest');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testIndexGet(): void {
Log::debug('inside testIndexGet ExternalProductCatalogsControllerTest');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test view method
*
* 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
{
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testViewGet(): void {
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ExternalProductCatalogs->find()->count();
public function testAddGet(): void {
$cntBefore = $this->ExternalProductCatalogs->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->ExternalProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ExternalProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$linksTable = TableRegistry::getTableLocator()->get('CakeProducts.ExternalProductCatalogsProductCatalogs');
$cntBefore = $this->ExternalProductCatalogs->find()->count();
$linksBefore = $linksTable->find()->count();
public function testAddPostSuccess(): void {
$linksTable = TableRegistry::getTableLocator()->get('CakeProducts.ExternalProductCatalogsProductCatalogs');
$cntBefore = $this->ExternalProductCatalogs->find()->count();
$linksBefore = $linksTable->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'add',
];
$data = [
'base_url' => 'http://localhost:8766',
'api_url' => 'http://localhost:8766/api/v1/',
'enabled' => true,
'external_product_catalogs_product_catalogs' => [
['product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428'],
]
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('external-product-catalogs');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'add',
];
$data = [
'base_url' => 'http://localhost:8766',
'api_url' => 'http://localhost:8766/api/v1/',
'enabled' => true,
'external_product_catalogs_product_catalogs' => [
['product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428'],
],
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('external-product-catalogs');
$cntAfter = $this->ExternalProductCatalogs->find()->count();
$linksAfter = $linksTable->find()->count();
$cntAfter = $this->ExternalProductCatalogs->find()->count();
$linksAfter = $linksTable->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEquals($linksBefore + 1, $linksAfter);
}
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEquals($linksBefore + 1, $linksAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ExternalProductCatalogs->find()->count();
public function testAddPostFailure(): void {
$cntBefore = $this->ExternalProductCatalogs->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'add',
];
$data = [
'product_catalog_id' => 999999,
'base_url' => '',
'api_url' => 'http://localhost:8766/api/v1/',
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'add',
];
$data = [
'product_catalog_id' => 999999,
'base_url' => '',
'api_url' => 'http://localhost:8766/api/v1/',
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(200);
$cntAfter = $this->ExternalProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ExternalProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'edit',
'115153f3-2f59-4234-8ff8-e1b205769999',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testEditGet(): void {
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'edit',
'115153f3-2f59-4234-8ff8-e1b205769999',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
$before = $this->ExternalProductCatalogs->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'edit',
$id,
];
$data = [
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'base_url' => 'http://localhost:8766',
'api_url' => 'http://localhost:8766/api/v1/',
'enabled' => true,
];
$this->put($url, $data);
public function testEditPutSuccess(): void {
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
$before = $this->ExternalProductCatalogs->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'edit',
$id,
];
$data = [
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'base_url' => 'http://localhost:8766',
'api_url' => 'http://localhost:8766/api/v1/',
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('external-product-catalogs');
$this->assertResponseCode(302);
$this->assertRedirectContains('external-product-catalogs');
$after = $this->ExternalProductCatalogs->get($id);
// assert saved properly below
}
$after = $this->ExternalProductCatalogs->get($id);
// assert saved properly below
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
$before = $this->ExternalProductCatalogs->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'edit',
$id,
];
$data = [
'product_catalog_id' => 9999999,
'base_url' => '',
'api_url' => 'http://localhost:8766/api/v1/',
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ExternalProductCatalogs->get($id);
public function testEditPutFailure(): void {
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205769999';
$before = $this->ExternalProductCatalogs->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'edit',
$id,
];
$data = [
'product_catalog_id' => 9999999,
'base_url' => '',
'api_url' => 'http://localhost:8766/api/v1/',
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ExternalProductCatalogs->get($id);
// assert save failed below
}
// assert save failed below
}
/**
/**
* Test delete method
*
* 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
{
$cntBefore = $this->ExternalProductCatalogs->find()->count();
public function testDelete(): void {
$cntBefore = $this->ExternalProductCatalogs->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'delete',
'115153f3-2f59-4234-8ff8-e1b205769999',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('external-product-catalogs');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogs',
'action' => 'delete',
'115153f3-2f59-4234-8ff8-e1b205769999',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('external-product-catalogs');
$cntAfter = $this->ExternalProductCatalogs->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
$cntAfter = $this->ExternalProductCatalogs->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
}
@@ -4,118 +4,111 @@ 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;
/**
protected $ExternalProductCatalogsProductCatalogs;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogs',
'plugin.CakeProducts.ProductCatalogs',
];
protected array $fixtures = [
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogs',
'plugin.CakeProducts.ProductCatalogs',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
protected function setUp(): void {
parent::setUp();
// $this->enableCsrfToken();
// $this->enableSecurityToken();
$this->disableErrorHandlerMiddleware();
$this->ExternalProductCatalogsProductCatalogs = $this->getTableLocator()->get('CakeProducts.ExternalProductCatalogsProductCatalogs');
}
$this->disableErrorHandlerMiddleware();
$this->ExternalProductCatalogsProductCatalogs = $this->getTableLocator()->get('CakeProducts.ExternalProductCatalogsProductCatalogs');
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ExternalProductCatalogsProductCatalogs);
protected function tearDown(): void {
unset($this->ExternalProductCatalogsProductCatalogs);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ExternalProductCatalogsProductCatalogs->find()->count();
public function testAddGet(): void {
$cntBefore = $this->ExternalProductCatalogsProductCatalogs->find()->count();
// $this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogsProductCatalogs',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
// $this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogsProductCatalogs',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->ExternalProductCatalogsProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ExternalProductCatalogsProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test delete method
*
* 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
{
$cntBeforeWithTrashed = $this->ExternalProductCatalogsProductCatalogs->find('withTrashed')->count();
$cntBefore = $this->ExternalProductCatalogsProductCatalogs->find()->count();
public function testDelete(): void {
$cntBeforeWithTrashed = $this->ExternalProductCatalogsProductCatalogs->find('withTrashed')->count();
$cntBefore = $this->ExternalProductCatalogsProductCatalogs->find()->count();
// $this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogsProductCatalogs',
'action' => 'delete',
1,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('external-product-catalogs');
// $this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ExternalProductCatalogsProductCatalogs',
'action' => 'delete',
1,
];
$this->delete($url);
$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);
}
$cntAfterWithTrashed = $this->ExternalProductCatalogsProductCatalogs->find('withTrashed')->count();
$cntAfter = $this->ExternalProductCatalogsProductCatalogs->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
$this->assertEquals($cntBeforeWithTrashed, $cntAfterWithTrashed);
}
}
@@ -3,325 +3,311 @@ 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;
protected $ProductCatalogs;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCatalogs',
'plugin.CakeProducts.ProductCategories',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductCatalogs',
'plugin.CakeProducts.ProductCategories',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
protected function setUp(): void {
parent::setUp();
// $this->enableCsrfToken();
// $this->enableSecurityToken();
$this->disableErrorHandlerMiddleware();
$config = $this->getTableLocator()->exists('ProductCatalogs') ? [] : ['className' => ProductCatalogsTable::class];
$this->ProductCatalogs = $this->getTableLocator()->get('ProductCatalogs', $config);
}
$this->disableErrorHandlerMiddleware();
$config = $this->getTableLocator()->exists('ProductCatalogs') ? [] : ['className' => ProductCatalogsTable::class];
$this->ProductCatalogs = $this->getTableLocator()->get('ProductCatalogs', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCatalogs);
protected function tearDown(): void {
unset($this->ProductCatalogs);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* Test index method
*
* 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
{
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testIndexGet(): void {
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test view method
*
* 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
{
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testViewGet(): void {
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCatalogs->find()->count();
public function testAddGet(): void {
$cntBefore = $this->ProductCatalogs->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->ProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCatalogs->find()->count();
public function testAddPostSuccess(): void {
$cntBefore = $this->ProductCatalogs->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'add',
];
$data = [
'name' => 'new catalog',
'catalog_description' => 'description',
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-catalogs');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'add',
];
$data = [
'name' => 'new catalog',
'catalog_description' => 'description',
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-catalogs');
$cntAfter = $this->ProductCatalogs->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
}
$cntAfter = $this->ProductCatalogs->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCatalogs->find()->count();
public function testAddPostFailure(): void {
$cntBefore = $this->ProductCatalogs->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'add',
];
$data = [
'name' => '',
'catalog_description' => '',
'enabled' => '',
];
$this->post($url, $data);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'add',
];
$data = [
'name' => '',
'catalog_description' => '',
'enabled' => '',
];
$this->post($url, $data);
$this->assertResponseCode(200);
$cntAfter = $this->ProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductCatalogs->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'edit',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testEditGet(): void {
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'edit',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
public function testEditPutSuccess(): void {
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
// $before = $this->ProductCatalogs->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'name' => 'edited name',
'catalog_description' => 'new catalog description',
'enabled' => true,
];
$this->put($url, $data);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'name' => 'edited name',
'catalog_description' => 'new catalog description',
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-catalogs');
$this->assertResponseCode(302);
$this->assertRedirectContains('product-catalogs');
$after = $this->ProductCatalogs->get($id);
$this->assertEquals($data['name'], $after->name);
$this->assertEquals($data['catalog_description'], $after->catalog_description);
// assert saved properly below
}
$after = $this->ProductCatalogs->get($id);
$this->assertEquals($data['name'], $after->name);
$this->assertEquals($data['catalog_description'], $after->catalog_description);
// assert saved properly below
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$before = $this->ProductCatalogs->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'edit',
$id,
];
$data = [
'name' => '',
'catalog_description' => 'edited description',
'enabled' => '',
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductCatalogs->get($id);
$this->assertEquals($before->name, $after->name);
$this->assertEquals($before->catalog_description, $after->catalog_description);
// assert save failed below
}
public function testEditPutFailure(): void {
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$before = $this->ProductCatalogs->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'edit',
$id,
];
$data = [
'name' => '',
'catalog_description' => 'edited description',
'enabled' => '',
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductCatalogs->get($id);
$this->assertEquals($before->name, $after->name);
$this->assertEquals($before->catalog_description, $after->catalog_description);
// assert save failed below
}
/**
/**
* Test delete method
*
* 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
{
$cntBefore = $this->ProductCatalogs->find()->count();
public function testDelete(): void {
$cntBefore = $this->ProductCatalogs->find()->count();
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'delete',
$id,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-catalogs');
$this->loginUserByRole('admin');
$id = '115153f3-2f59-4234-8ff8-e1b205761428';
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCatalogs',
'action' => 'delete',
$id,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-catalogs');
$cntAfter = $this->ProductCatalogs->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
$cntAfter = $this->ProductCatalogs->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
}
@@ -3,334 +3,310 @@ 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;
protected $ProductCategories;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCatalogs',
'plugin.CakeProducts.ProductCategories',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductCatalogs',
'plugin.CakeProducts.ProductCategories',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
protected function setUp(): void {
parent::setUp();
// $this->enableCsrfToken();
// $this->enableSecurityToken();
$this->disableErrorHandlerMiddleware();
$this->ProductCategories = $this->getTableLocator()->get('CakeProducts.ProductCategories');
}
$this->disableErrorHandlerMiddleware();
$this->ProductCategories = $this->getTableLocator()->get('CakeProducts.ProductCategories');
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCategories);
protected function tearDown(): void {
unset($this->ProductCategories);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* Test index method
*
* 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
{
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testIndexGet(): void {
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test view method
*
* 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
{
$id = 1;
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testViewGet(): void {
$id = 1;
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategories->find()->count();
public function testAddGet(): void {
$cntBefore = $this->ProductCategories->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->ProductCategories->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductCategories->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategories->find()->count();
public function testAddPostSuccess(): void {
$cntBefore = $this->ProductCategories->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'add',
];
$data = [
'name' => 'Electrical Plugs',
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'category_description' => 'electrical',
'parent_id' => 3,
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-categories');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'add',
];
$data = [
'name' => 'Electrical Plugs',
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'category_description' => 'electrical',
'parent_id' => 3,
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-categories');
$cntAfter = $this->ProductCategories->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
}
$cntAfter = $this->ProductCategories->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategories->find()->count();
public function testAddPostFailure(): void {
$cntBefore = $this->ProductCategories->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'add',
];
$data = [
'name' => '',
'product_catalog_id' => '',
'category_description' => 'electrical',
'parent_id' => '',
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'add',
];
$data = [
'name' => '',
'product_catalog_id' => '',
'category_description' => 'electrical',
'parent_id' => '',
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(200);
$cntAfter = $this->ProductCategories->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductCategories->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'edit',
1,
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testEditGet(): void {
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'edit',
1,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = 1;
$before = $this->ProductCategories->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'name' => 'Electrical v2',
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'category_description' => 'electrical v2',
'parent_id' => '',
'enabled' => true,
];
$this->put($url, $data);
public function testEditPutSuccess(): void {
$this->loginUserByRole('admin');
$id = 1;
$before = $this->ProductCategories->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'name' => 'Electrical v2',
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'category_description' => 'electrical v2',
'parent_id' => '',
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-categories');
$this->assertResponseCode(302);
$this->assertRedirectContains('product-categories');
$after = $this->ProductCategories->get($id);
$this->assertEquals($data['name'], $after->name);
$this->assertEquals($data['product_catalog_id'], $after->product_catalog_id);
$this->assertEquals($data['category_description'], $after->category_description);
$this->assertNull($after->parent_id);
// assert saved properly below
}
$after = $this->ProductCategories->get($id);
$this->assertEquals($data['name'], $after->name);
$this->assertEquals($data['product_catalog_id'], $after->product_catalog_id);
$this->assertEquals($data['category_description'], $after->category_description);
$this->assertNull($after->parent_id);
// assert saved properly below
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = 1;
$before = $this->ProductCategories->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'edit',
$id,
];
$data = [
'name' => '',
'product_catalog_id' => '',
'category_description' => 'electrical',
'parent_id' => '',
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductCategories->get($id);
public function testEditPutFailure(): void {
$this->loginUserByRole('admin');
$id = 1;
$before = $this->ProductCategories->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'edit',
$id,
];
$data = [
'name' => '',
'product_catalog_id' => '',
'category_description' => 'electrical',
'parent_id' => '',
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductCategories->get($id);
// assert save failed below
}
// assert save failed below
}
/**
/**
* 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
{
$cntBefore = $this->ProductCategories->find()->count();
$cntBeforeWithTrashed = $this->ProductCategories->find('withTrashed')->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'delete',
1,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-categories');
public function testDelete(): void {
$cntBefore = $this->ProductCategories->find()->count();
$cntBeforeWithTrashed = $this->ProductCategories->find('withTrashed')->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategories',
'action' => 'delete',
1,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-categories');
$cntAfter = $this->ProductCategories->find()->count();
$cntAfterWithTrashed = $this->ProductCategories->find('withTrashed')->count();
$cntAfter = $this->ProductCategories->find()->count();
$cntAfterWithTrashed = $this->ProductCategories->find('withTrashed')->count();
$this->assertEquals($cntBefore - 2, $cntAfter); // has 1 child category
$this->assertEquals($cntBeforeWithTrashed, $cntAfterWithTrashed);
}
$this->assertEquals($cntBefore - 2, $cntAfter); // has 1 child category
$this->assertEquals($cntBeforeWithTrashed, $cntAfterWithTrashed);
}
}
@@ -3,142 +3,133 @@ 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;
protected $ProductCategoryAttributeOptions;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryAttributeOptions',
'plugin.CakeProducts.ProductCategoryAttributes',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryAttributeOptions',
'plugin.CakeProducts.ProductCategoryAttributes',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
protected function setUp(): void {
parent::setUp();
// $this->enableCsrfToken();
// $this->enableSecurityToken();
$config = $this->getTableLocator()->exists('ProductCategoryAttributeOptions') ? [] : ['className' => ProductCategoryAttributeOptionsTable::class];
$this->ProductCategoryAttributeOptions = $this->getTableLocator()->get('ProductCategoryAttributeOptions', $config);
}
$config = $this->getTableLocator()->exists('ProductCategoryAttributeOptions') ? [] : ['className' => ProductCategoryAttributeOptionsTable::class];
$this->ProductCategoryAttributeOptions = $this->getTableLocator()->get('ProductCategoryAttributeOptions', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCategoryAttributeOptions);
protected function tearDown(): void {
unset($this->ProductCategoryAttributeOptions);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
public function testAddGet(): void {
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributeOptions',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributeOptions',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->ProductCategoryAttributeOptions->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductCategoryAttributeOptions->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
public function testAddPostHasNoEffect(): void {
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributeOptions',
'action' => 'add',
];
$data = [];
$this->post($url, $data);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributeOptions',
'action' => 'add',
];
$data = [];
$this->post($url, $data);
$this->assertResponseCode(200);
$cntAfter = $this->ProductCategoryAttributeOptions->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductCategoryAttributeOptions->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test delete method
*
* 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
{
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
public function testDelete(): void {
$cntBefore = $this->ProductCategoryAttributeOptions->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributeOptions',
'action' => 'delete',
'e06f1723-2456-483a-b3c4-004603e032a8',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-attributes');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributeOptions',
'action' => 'delete',
'e06f1723-2456-483a-b3c4-004603e032a8',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-attributes');
$cntAfter = $this->ProductCategoryAttributeOptions->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
$cntAfter = $this->ProductCategoryAttributeOptions->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
}
@@ -3,373 +3,348 @@ 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;
protected $ProductCategoryAttributes;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryAttributes',
'plugin.CakeProducts.ProductCategories',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryAttributes',
'plugin.CakeProducts.ProductCategories',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
protected function setUp(): void {
parent::setUp();
// $this->enableCsrfToken();
// $this->enableSecurityToken();
$config = $this->getTableLocator()->exists('ProductCategoryAttributes') ? [] : ['className' => ProductCategoryAttributesTable::class];
$this->ProductCategoryAttributes = $this->getTableLocator()->get('ProductCategoryAttributes', $config);
}
$config = $this->getTableLocator()->exists('ProductCategoryAttributes') ? [] : ['className' => ProductCategoryAttributesTable::class];
$this->ProductCategoryAttributes = $this->getTableLocator()->get('ProductCategoryAttributes', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCategoryAttributes);
protected function tearDown(): void {
unset($this->ProductCategoryAttributes);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* Test index method
*
* 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
{
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testIndexGet(): void {
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test view method
*
* 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
{
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testViewGet(): void {
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
public function testAddGet(): void {
$cntBefore = $this->ProductCategoryAttributes->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
public function testAddPostSuccess(): void {
$cntBefore = $this->ProductCategoryAttributes->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'add',
];
$data = [
'name' => 'Size',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'attribute_type_id' => 2,
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-attributes');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'add',
];
$data = [
'name' => 'Size',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'attribute_type_id' => 2,
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-attributes');
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
}
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
$cntOptionsBefore = $this->ProductCategoryAttributes->ProductCategoryAttributeOptions->find()->count();
public function testAddPostSuccessConstrainedWithOptions(): void {
$cntBefore = $this->ProductCategoryAttributes->find()->count();
$cntOptionsBefore = $this->ProductCategoryAttributes->ProductCategoryAttributeOptions->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'add',
];
$data = [
'name' => 'Size',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'attribute_type_id' => 1,
'enabled' => true,
'product_category_attribute_options' => [
[
'attribute_value' => 'XL',
'attribute_label' => 'XL',
'enabled' => true,
],
[
'attribute_value' => 'L',
'attribute_label' => 'L',
'enabled' => true,
]
],
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-attributes');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'add',
];
$data = [
'name' => 'Size',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'attribute_type_id' => 1,
'enabled' => true,
'product_category_attribute_options' => [
[
'attribute_value' => 'XL',
'attribute_label' => 'XL',
'enabled' => true,
],
[
'attribute_value' => 'L',
'attribute_label' => 'L',
'enabled' => true,
],
],
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-attributes');
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$cntOptionsAfter = $this->ProductCategoryAttributes->ProductCategoryAttributeOptions->find()->count();
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$cntOptionsAfter = $this->ProductCategoryAttributes->ProductCategoryAttributeOptions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEquals($cntOptionsBefore + 2, $cntOptionsAfter);
}
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEquals($cntOptionsBefore + 2, $cntOptionsAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
public function testAddPostFailure(): void {
$cntBefore = $this->ProductCategoryAttributes->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'add',
];
$data = [
'name' => '',
'product_category_id' => 1,
'attribute_type_id' => 1,
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'add',
];
$data = [
'name' => '',
'product_category_id' => 1,
'attribute_type_id' => 1,
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(200);
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'edit',
'37078cf0-0130-4b93-bb7e-abe7d665ed2c',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testEditGet(): void {
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'edit',
'37078cf0-0130-4b93-bb7e-abe7d665ed2c',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
$before = $this->ProductCategoryAttributes->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'name' => 'Color',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'attribute_type_id' => 1,
'enabled' => true,
];
$this->put($url, $data);
public function testEditPutSuccess(): void {
$this->loginUserByRole('admin');
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
$before = $this->ProductCategoryAttributes->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'name' => 'Color',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'attribute_type_id' => 1,
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-attributes');
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-attributes');
$after = $this->ProductCategoryAttributes->get($id);
// assert saved properly below
}
$after = $this->ProductCategoryAttributes->get($id);
// assert saved properly below
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
$before = $this->ProductCategoryAttributes->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'edit',
$id,
];
$data = [
'name' => '',
'product_category_id' => 1,
'attribute_type_id' => 1,
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductCategoryAttributes->get($id);
public function testEditPutFailure(): void {
$this->loginUserByRole('admin');
$id = '37078cf0-0130-4b93-bb7e-abe7d665ed2c';
$before = $this->ProductCategoryAttributes->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'edit',
$id,
];
$data = [
'name' => '',
'product_category_id' => 1,
'attribute_type_id' => 1,
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductCategoryAttributes->get($id);
// assert save failed below
}
// assert save failed below
}
/**
/**
* 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
{
$cntBefore = $this->ProductCategoryAttributes->find()->count();
public function testDelete(): void {
$cntBefore = $this->ProductCategoryAttributes->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'delete',
'37078cf0-0130-4b93-bb7e-abe7d665ed2c',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-attributes');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryAttributes',
'action' => 'delete',
'37078cf0-0130-4b93-bb7e-abe7d665ed2c',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-attributes');
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
$cntAfter = $this->ProductCategoryAttributes->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
}
@@ -3,425 +3,412 @@ 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
{
/**
* Test subject
*
* @var ProductCategoryVariantsTable|Table
*/
protected $ProductCategoryVariants;
class ProductCategoryVariantsControllerTest extends BaseControllerTest {
/**
/**
* Test subject
*
* @var ProductCategoryVariantOptionsTable|Table
* @var \CakeProducts\Model\Table\ProductCategoryVariantsTable|\Cake\ORM\Table
*/
protected $ProductCategoryVariantOptions;
/**
protected $ProductCategoryVariants;
/**
* Test subject
*
* @var \CakeProducts\Model\Table\ProductCategoryVariantOptionsTable|\Cake\ORM\Table
*/
protected $ProductCategoryVariantOptions;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryVariants',
'plugin.CakeProducts.ProductCategoryVariantOptions',
'plugin.CakeProducts.ProductVariants',
'plugin.CakeProducts.ProductCategories',
'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductSkus',
'plugin.CakeProducts.ProductPhotos',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryVariants',
'plugin.CakeProducts.ProductCategoryVariantOptions',
'plugin.CakeProducts.ProductVariants',
'plugin.CakeProducts.ProductCategories',
'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductSkus',
'plugin.CakeProducts.ProductPhotos',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->disableErrorHandlerMiddleware();
protected function setUp(): void {
parent::setUp();
$this->disableErrorHandlerMiddleware();
$config = $this->getTableLocator()->exists('ProductCategoryVariants') ? [] : ['className' => ProductCategoryVariantsTable::class];
$this->ProductCategoryVariants = $this->getTableLocator()->get('ProductCategoryVariants', $config);
$config = $this->getTableLocator()->exists('ProductCategoryVariants') ? [] : ['className' => ProductCategoryVariantsTable::class];
$this->ProductCategoryVariants = $this->getTableLocator()->get('ProductCategoryVariants', $config);
$config = $this->getTableLocator()->exists('ProductCategoryVariantOptions') ? [] : ['className' => ProductCategoryVariantOptionsTable::class];
$this->ProductCategoryVariantOptions = $this->getTableLocator()->get('ProductCategoryVariantOptions', $config);
}
$config = $this->getTableLocator()->exists('ProductCategoryVariantOptions') ? [] : ['className' => ProductCategoryVariantOptionsTable::class];
$this->ProductCategoryVariantOptions = $this->getTableLocator()->get('ProductCategoryVariantOptions', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCategoryVariants);
unset($this->ProductCategoryVariantOptions);
protected function tearDown(): void {
unset($this->ProductCategoryVariants);
unset($this->ProductCategoryVariantOptions);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* Test index method
*
* 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
{
//$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testIndexGet(): void {
//$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test view method
*
* 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
{
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
//$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testViewGet(): void {
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
//$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategoryVariants->find()->count();
public function testAddGet(): void {
$cntBefore = $this->ProductCategoryVariants->find()->count();
//$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
//$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->ProductCategoryVariants->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductCategoryVariants->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategoryVariants->find()->count();
$cntBeforeOptions = $this->ProductCategoryVariantOptions->find()->count();
public function testAddPostLoggedInSuccess(): void {
$cntBefore = $this->ProductCategoryVariants->find()->count();
$cntBeforeOptions = $this->ProductCategoryVariantOptions->find()->count();
//$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'add',
];
$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');
//$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'add',
];
$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);
}
$cntAfter = $this->ProductCategoryVariants->find()->count();
$cntAfterOptions = $this->ProductCategoryVariantOptions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEquals($cntBeforeOptions + 2, $cntAfterOptions);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductCategoryVariants->find()->count();
public function testAddPostLoggedInFailure(): void {
$cntBefore = $this->ProductCategoryVariants->find()->count();
//$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'add',
];
$data = [
'name' => '',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(200);
//$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'add',
];
$data = [
'name' => '',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'enabled' => true,
];
$this->post($url, $data);
$this->assertResponseCode(200);
$cntAfter = $this->ProductCategoryVariants->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductCategoryVariants->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test edit method
*
* 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
{
//$this->loginUserByRole('admin');
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
public function testEditGet(): void {
//$this->loginUserByRole('admin');
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'edit',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'edit',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test edit method
*
* 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
{
//$this->loginUserByRole('admin');
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
$before = $this->ProductCategoryVariants->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'name' => 'updated name',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'enabled' => true,
];
$this->put($url, $data);
public function testEditPutLoggedInSuccess(): void {
//$this->loginUserByRole('admin');
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
$before = $this->ProductCategoryVariants->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'name' => 'updated name',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-variants');
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-variants');
$after = $this->ProductCategoryVariants->get($id);
// assert saved properly below
}
$after = $this->ProductCategoryVariants->get($id);
// assert saved properly below
}
/**
/**
* Test edit method
*
* 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
{
//$this->loginUserByRole('admin');
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78222'; // subscription length
$before = $this->ProductCategoryVariants->get($id);
$cntBeforeOptions = $this->ProductCategoryVariantOptions
->find()
->where(['product_category_variant_id' => $id])
->toArray();
public function testEditPutLoggedInSuccessSystemVariant(): void {
//$this->loginUserByRole('admin');
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78222'; // subscription length
$before = $this->ProductCategoryVariants->get($id);
$cntBeforeOptions = $this->ProductCategoryVariantOptions
->find()
->where(['product_category_variant_id' => $id])
->toArray();
// $this->assertEquals(2, count($cntBeforeOptions));
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'name' => 'updated name',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'enabled' => false,
'product_category_variant_options' => [
[
'variant_value' => '14',
'variant_label' => '14',
'enabled' => true,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f22221',
'variant_value' => '6',
'variant_label' => '6',
'enabled' => true,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f22222',
'variant_value' => 12,
'variant_label' => 12,
'enabled' => true,
],
],
];
$this->put($url, $data);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'name' => 'updated name',
'product_category_id' => 'db4b4273-eddc-46d4-93c8-45cf7c6e058e',
'enabled' => false,
'product_category_variant_options' => [
[
'variant_value' => '14',
'variant_label' => '14',
'enabled' => true,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f22221',
'variant_value' => '6',
'variant_label' => '6',
'enabled' => true,
],
[
'id' => '5a386e9f-6e7a-4ae7-9360-c8e529f22222',
'variant_value' => 12,
'variant_label' => 12,
'enabled' => true,
],
],
];
$this->put($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-variants');
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-variants');
$after = $this->ProductCategoryVariants->get($id);
$cntAfterOptions = $this->ProductCategoryVariantOptions
->find()
->where(['product_category_variant_id' => $id])
->toArray();
$after = $this->ProductCategoryVariants->get($id);
$cntAfterOptions = $this->ProductCategoryVariantOptions
->find()
->where(['product_category_variant_id' => $id])
->toArray();
$this->assertEquals(count($cntBeforeOptions) + 1, count($cntAfterOptions));
$this->assertEquals(count($cntBeforeOptions) + 1, count($cntAfterOptions));
$this->assertEquals($before->name, $after->name);
$this->assertNull($after->product_category_id);
$this->assertTrue($after->enabled);
// assert saved properly below
}
$this->assertEquals($before->name, $after->name);
$this->assertNull($after->product_category_id);
$this->assertTrue($after->enabled);
// assert saved properly below
}
/**
/**
* Test edit method
*
* 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
{
//$this->loginUserByRole('admin');
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
$before = $this->ProductCategoryVariants->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'edit',
$id,
];
$data = [
'name' => '',
'product_category_id' => 'NOT A VALID ID',
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductCategoryVariants->get($id);
public function testEditPutLoggedInFailure(): void {
//$this->loginUserByRole('admin');
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
$before = $this->ProductCategoryVariants->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'edit',
$id,
];
$data = [
'name' => '',
'product_category_id' => 'NOT A VALID ID',
'enabled' => true,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductCategoryVariants->get($id);
// assert save failed below
}
// assert save failed below
}
/**
/**
* Test delete method
*
* 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
{
$cntBefore = $this->ProductCategoryVariants->find()->count();
public function testDelete(): void {
$cntBefore = $this->ProductCategoryVariants->find()->count();
//$this->loginUserByRole('admin');
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
//$this->loginUserByRole('admin');
$id = '5a386e9f-6e7a-4ae7-9360-c8e529f78d93';
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'delete',
$id,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-variants');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductCategoryVariants',
'action' => 'delete',
$id,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-category-variants');
$cntAfter = $this->ProductCategoryVariants->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
$cntAfter = $this->ProductCategoryVariants->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
}
File diff suppressed because it is too large Load Diff
@@ -3,355 +3,340 @@ 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;
protected $ProductSkus;
/**
/**
* Test subject table
*
* @var ProductSkuVariantValuesTable|Table
* @var \CakeProducts\Model\Table\ProductSkuVariantValuesTable|\Cake\ORM\Table
*/
protected $ProductSkuVariantValues;
protected $ProductSkuVariantValues;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductSkus',
'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductAttributes',
'plugin.CakeProducts.ProductVariants',
'plugin.CakeProducts.ProductCategoryVariants',
'plugin.CakeProducts.ProductCategoryVariantOptions',
'plugin.CakeProducts.ProductSkuVariantValues',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductSkus',
'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductAttributes',
'plugin.CakeProducts.ProductVariants',
'plugin.CakeProducts.ProductCategoryVariants',
'plugin.CakeProducts.ProductCategoryVariantOptions',
'plugin.CakeProducts.ProductSkuVariantValues',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
protected function setUp(): void {
parent::setUp();
// $this->enableCsrfToken();
// $this->enableSecurityToken();
$this->disableErrorHandlerMiddleware();
$this->disableErrorHandlerMiddleware();
$config = $this->getTableLocator()->exists('ProductSkus') ? [] : ['className' => ProductSkusTable::class];
$this->ProductSkus = $this->getTableLocator()->get('ProductSkus', $config);
$config = $this->getTableLocator()->exists('ProductSkus') ? [] : ['className' => ProductSkusTable::class];
$this->ProductSkus = $this->getTableLocator()->get('ProductSkus', $config);
$config = $this->getTableLocator()->exists('ProductSkuVariantValues') ? [] : ['className' => ProductSkuVariantValuesTable::class];
$this->ProductSkuVariantValues = $this->getTableLocator()->get('ProductSkuVariantValues', $config);
}
$config = $this->getTableLocator()->exists('ProductSkuVariantValues') ? [] : ['className' => ProductSkuVariantValuesTable::class];
$this->ProductSkuVariantValues = $this->getTableLocator()->get('ProductSkuVariantValues', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductSkus);
protected function tearDown(): void {
unset($this->ProductSkus);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* Test index method
*
* 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
{
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testIndexGet(): void {
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test view method
*
* 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
{
$id = '3a477e3e-7977-4813-81f6-f85949613979';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testViewGet(): void {
$id = '3a477e3e-7977-4813-81f6-f85949613979';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductSkus->find()->count();
public function testAddGet(): void {
$cntBefore = $this->ProductSkus->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'add',
'cfc98a9a-29b2-44c8-b587-8156adc05317'
];
$this->get($url);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'add',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->ProductSkus->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductSkus->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductSkus->find()->count();
$cntVariantValuesBefore = $this->ProductSkuVariantValues->find()->count();
public function testAddPostSuccess(): void {
$cntBefore = $this->ProductSkus->find()->count();
$cntVariantValuesBefore = $this->ProductSkuVariantValues->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'add',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$data = [
0 => [
'sku' => 'cfc98a9a-29b2-44c8-b587-8156a',
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156a',
'price' => 1.5,
'cost' => 1.5,
'product_sku_variant_values' => [
0 => [
'product_variant_id' => '2e6e4031-c430-4d07-b8d6-a4e759b72568',
'product_category_variant_option_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d23',
],
],
],
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-skus');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'add',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$data = [
0 => [
'sku' => 'cfc98a9a-29b2-44c8-b587-8156a',
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156a',
'price' => 1.5,
'cost' => 1.5,
'product_sku_variant_values' => [
0 => [
'product_variant_id' => '2e6e4031-c430-4d07-b8d6-a4e759b72568',
'product_category_variant_option_id' => '5a386e9f-6e7a-4ae7-9360-c8e529f78d23',
],
],
],
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-skus');
$cntAfter = $this->ProductSkus->find()->count();
$cntVariantValuesAfter = $this->ProductSkuVariantValues->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEquals($cntVariantValuesBefore + 1, $cntVariantValuesAfter);
}
$cntAfter = $this->ProductSkus->find()->count();
$cntVariantValuesAfter = $this->ProductSkuVariantValues->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEquals($cntVariantValuesBefore + 1, $cntVariantValuesAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->ProductSkus->find()->count();
public function testAddPostFailure(): void {
$cntBefore = $this->ProductSkus->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'add',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$data = [
0 => [
'sku' => '',
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'price' => 1.5,
'cost' => 1.5,
],
];
$this->post($url, $data);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'add',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$data = [
0 => [
'sku' => '',
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'price' => 1.5,
'cost' => 1.5,
],
];
$this->post($url, $data);
$this->assertResponseCode(200);
$cntAfter = $this->ProductSkus->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->ProductSkus->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'edit',
'3a477e3e-7977-4813-81f6-f85949613979',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testEditGet(): void {
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'edit',
'3a477e3e-7977-4813-81f6-f85949613979',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = '3a477e3e-7977-4813-81f6-f85949613979';
$before = $this->ProductSkus->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'edit',
$id,
];
$data = [
// test new data here
];
$this->put($url, $data);
public function testEditPutSuccess(): void {
$this->loginUserByRole('admin');
$id = '3a477e3e-7977-4813-81f6-f85949613979';
$before = $this->ProductSkus->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'edit',
$id,
];
$data = [
// test new data here
];
$this->put($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-skus');
$this->assertResponseCode(302);
$this->assertRedirectContains('product-skus');
$after = $this->ProductSkus->get($id);
// assert saved properly below
}
$after = $this->ProductSkus->get($id);
// assert saved properly below
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = '3a477e3e-7977-4813-81f6-f85949613979';
$before = $this->ProductSkus->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'edit',
$id,
];
$data = [
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'sku' => '',
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'price' => 1.5,
'cost' => 1.5,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductSkus->get($id);
public function testEditPutFailure(): void {
$this->loginUserByRole('admin');
$id = '3a477e3e-7977-4813-81f6-f85949613979';
$before = $this->ProductSkus->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'edit',
$id,
];
$data = [
'product_id' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'sku' => '',
'barcode' => 'cfc98a9a-29b2-44c8-b587-8156adc05317',
'price' => 1.5,
'cost' => 1.5,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductSkus->get($id);
// assert save failed below
}
// assert save failed below
}
/**
/**
* Test delete method
*
* 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
{
$cntBefore = $this->ProductSkus->find()->count();
public function testDelete(): void {
$cntBefore = $this->ProductSkus->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'delete',
'3a477e3e-7977-4813-81f6-f85949613979',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-skus');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'ProductSkus',
'action' => 'delete',
'3a477e3e-7977-4813-81f6-f85949613979',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-skus');
$cntAfter = $this->ProductSkus->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
$cntAfter = $this->ProductSkus->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
}
@@ -3,343 +3,318 @@ 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;
protected $Products;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductAttributes',
'plugin.CakeProducts.ProductCategories',
'plugin.CakeProducts.ProductCategoryAttributes',
'plugin.CakeProducts.ProductCategoryAttributeOptions',
protected array $fixtures = [
'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductAttributes',
'plugin.CakeProducts.ProductCategories',
'plugin.CakeProducts.ProductCategoryAttributes',
'plugin.CakeProducts.ProductCategoryAttributeOptions',
// 'plugin.CakeProducts.ProductCatalogs',
];
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
protected function setUp(): void {
parent::setUp();
// $this->enableCsrfToken();
// $this->enableSecurityToken();
$config = $this->getTableLocator()->exists('Products') ? [] : ['className' => ProductsTable::class];
$this->Products = $this->getTableLocator()->get('Products', $config);
}
$config = $this->getTableLocator()->exists('Products') ? [] : ['className' => ProductsTable::class];
$this->Products = $this->getTableLocator()->get('Products', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Products);
protected function tearDown(): void {
unset($this->Products);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* Test index method
*
* 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
{
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testIndexGet(): void {
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test view method
*
* 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
{
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testViewGet(): void {
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->Products->find()->count();
public function testAddGet(): void {
$cntBefore = $this->Products->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->Products->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->Products->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test add method
*
* 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
{
$cntBefore = $this->Products->find()->count();
$productAttributesCntBefore = $this->Products->ProductAttributes->find()->count();
public function testAddPostSuccess(): void {
$cntBefore = $this->Products->find()->count();
$productAttributesCntBefore = $this->Products->ProductAttributes->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'add',
];
$data = [
// test new data here
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'name' => '14AWG Red Wire',
'product_type_id' => 1,
'product_attributes' => [
[
'product_category_attribute_id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
'product_category_attribute_option_id' => 'e06f1723-2456-483a-b3c4-004603e032a2', // green
'attribute_value' => '',
],
],
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('products');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'add',
];
$data = [
// test new data here
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'name' => '14AWG Red Wire',
'product_type_id' => 1,
'product_attributes' => [
[
'product_category_attribute_id' => '37078cf0-0130-4b93-bb7e-abe7d665ed2c',
'product_category_attribute_option_id' => 'e06f1723-2456-483a-b3c4-004603e032a2', // green
'attribute_value' => '',
],
],
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('products');
$cntAfter = $this->Products->find()->count();
$productAttributesCntAfter = $this->Products->ProductAttributes->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEquals($productAttributesCntBefore + 1, $productAttributesCntAfter);
}
$cntAfter = $this->Products->find()->count();
$productAttributesCntAfter = $this->Products->ProductAttributes->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$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
{
$cntBefore = $this->Products->find()->count();
public function testAddPostFailure(): void {
$cntBefore = $this->Products->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'add',
];
$data = [
'product_catalog_id' => '',
'product_category_id' => '',
'name' => '',
'product_type_id' => 1,
'product_attributes' => [],
];
$this->post($url, $data);
$this->assertResponseCode(200);
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'add',
];
$data = [
'product_catalog_id' => '',
'product_category_id' => '',
'name' => '',
'product_type_id' => 1,
'product_attributes' => [],
];
$this->post($url, $data);
$this->assertResponseCode(200);
$cntAfter = $this->Products->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
$cntAfter = $this->Products->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'edit',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$this->get($url);
$this->assertResponseCode(200);
}
public function testEditGet(): void {
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'edit',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$before = $this->Products->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'name' => 'edited product name',
'product_type_id' => 1,
];
$this->put($url, $data);
public function testEditPutSuccess(): void {
$this->loginUserByRole('admin');
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$before = $this->Products->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'product_catalog_id' => '115153f3-2f59-4234-8ff8-e1b205761428',
'product_category_id' => '6d223283-361b-4f9f-a7f1-c97aa0ca4c23',
'name' => 'edited product name',
'product_type_id' => 1,
];
$this->put($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('products');
$this->assertResponseCode(302);
$this->assertRedirectContains('products');
$after = $this->Products->get($id);
$this->assertEquals($data['name'], $after->name);
// assert saved properly below
}
$after = $this->Products->get($id);
$this->assertEquals($data['name'], $after->name);
// assert saved properly below
}
/**
/**
* Test edit method
*
* 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
{
$this->loginUserByRole('admin');
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$before = $this->Products->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'edit',
$id,
];
$data = [
'product_catalog_id' => '',
'product_category_id' => '',
'name' => 'edited name not gonna take',
'product_type_id' => 1,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->Products->get($id);
$this->assertEquals($before->name, $after->name);
$this->assertEquals($before->product_category_id, $after->product_category_id);
// assert save failed below
}
public function testEditPutFailure(): void {
$this->loginUserByRole('admin');
$id = 'cfc98a9a-29b2-44c8-b587-8156adc05317';
$before = $this->Products->get($id);
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'edit',
$id,
];
$data = [
'product_catalog_id' => '',
'product_category_id' => '',
'name' => 'edited name not gonna take',
'product_type_id' => 1,
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->Products->get($id);
$this->assertEquals($before->name, $after->name);
$this->assertEquals($before->product_category_id, $after->product_category_id);
// assert save failed below
}
/**
/**
* 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
{
$cntBefore = $this->Products->find()->count();
public function testDelete(): void {
$cntBefore = $this->Products->find()->count();
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'delete',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('products');
$this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeProducts',
'controller' => 'Products',
'action' => 'delete',
'cfc98a9a-29b2-44c8-b587-8156adc05317',
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('products');
$cntAfter = $this->Products->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
$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,102 +11,98 @@ 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;
protected $ExternalProductCatalogs;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ExternalProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ProductCatalogs',
];
protected array $fixtures = [
'plugin.CakeProducts.ExternalProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ProductCatalogs',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('ExternalProductCatalogs') ? [] : ['className' => ExternalProductCatalogsTable::class];
$this->ExternalProductCatalogs = $this->getTableLocator()->get('ExternalProductCatalogs', $config);
}
protected function setUp(): void {
parent::setUp();
$config = $this->getTableLocator()->exists('ExternalProductCatalogs') ? [] : ['className' => ExternalProductCatalogsTable::class];
$this->ExternalProductCatalogs = $this->getTableLocator()->get('ExternalProductCatalogs', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ExternalProductCatalogs);
protected function tearDown(): void {
unset($this->ExternalProductCatalogs);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* TestInitialize method
*
* @return void
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::initialize
* @return void
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'ProductCatalogs',
'ExternalProductCatalogsProductCatalogs',
];
$associations = $this->ExternalProductCatalogs->associations();
public function testInitialize(): void {
// verify all associations loaded
$expectedAssociations = [
'ProductCatalogs',
'ExternalProductCatalogsProductCatalogs',
];
$associations = $this->ExternalProductCatalogs->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ExternalProductCatalogs->hasAssociation($expectedAssociation));
}
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ExternalProductCatalogs->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [
'Timestamp',
'Trash',
];
$behaviors = $this->ExternalProductCatalogs->behaviors();
// verify all behaviors loaded
$expectedBehaviors = [
'Timestamp',
'Trash',
];
$behaviors = $this->ExternalProductCatalogs->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ExternalProductCatalogs->hasBehavior($expectedBehavior));
}
}
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ExternalProductCatalogs->hasBehavior($expectedBehavior));
}
}
/**
/**
* Test validationDefault method
*
* @return void
* @uses \CakeProducts\Model\Table\ExternalProductCatalogsTable::validationDefault
* @return void
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
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
{
$this->markTestIncomplete('Not implemented yet.');
}
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,90 +11,87 @@ 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;
protected $ProductCatalogs;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ProductCategories',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductCatalogs',
'plugin.CakeProducts.ExternalProductCatalogsProductCatalogs',
'plugin.CakeProducts.ProductCategories',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCatalogs') ? [] : ['className' => ProductCatalogsTable::class];
$this->ProductCatalogs = $this->getTableLocator()->get('ProductCatalogs', $config);
}
protected function setUp(): void {
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCatalogs') ? [] : ['className' => ProductCatalogsTable::class];
$this->ProductCatalogs = $this->getTableLocator()->get('ProductCatalogs', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCatalogs);
protected function tearDown(): void {
unset($this->ProductCatalogs);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* TestInitialize method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductCatalogsTable::initialize
* @return void
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'ProductCategories',
'ExternalProductCatalogs',
];
$associations = $this->ProductCatalogs->associations();
public function testInitialize(): void {
// verify all associations loaded
$expectedAssociations = [
'ProductCategories',
'ExternalProductCatalogs',
];
$associations = $this->ProductCatalogs->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCatalogs->hasAssociation($expectedAssociation));
}
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCatalogs->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [
'Trash',
];
$behaviors = $this->ProductCatalogs->behaviors();
// verify all behaviors loaded
$expectedBehaviors = [
'Trash',
];
$behaviors = $this->ProductCatalogs->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCatalogs->hasBehavior($expectedBehavior));
}
}
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCatalogs->hasBehavior($expectedBehavior));
}
}
/**
/**
* Test validationDefault method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductCatalogsTable::validationDefault
* @return void
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
public function testValidationDefault(): void {
$this->markTestIncomplete('Not implemented yet.');
}
}
@@ -11,107 +11,103 @@ use PHPUnit\Framework\Attributes\CoversClass;
* CakeProducts\Model\Table\ProductCategoriesTable Test Case
*/
#[CoversClass(ProductCategoriesTable::class)]
class ProductCategoriesTableTest extends TestCase
{
/**
class ProductCategoriesTableTest extends TestCase {
/**
* Test subject
*
* @var \CakeProducts\Model\Table\ProductCategoriesTable
*/
protected $ProductCategories;
protected $ProductCategories;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCategories',
'plugin.CakeProducts.ProductCatalogs',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductCategories',
'plugin.CakeProducts.ProductCatalogs',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCategories') ? [] : ['className' => ProductCategoriesTable::class];
$this->ProductCategories = $this->getTableLocator()->get('ProductCategories', $config);
}
protected function setUp(): void {
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCategories') ? [] : ['className' => ProductCategoriesTable::class];
$this->ProductCategories = $this->getTableLocator()->get('ProductCategories', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCategories);
protected function tearDown(): void {
unset($this->ProductCategories);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* TestInitialize method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductCategoriesTable::initialize()
* @return void
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'ProductCatalogs',
'ParentProductCategories',
'ChildProductCategories',
'Products',
'ProductCategoryAttributes',
'ProductCategoryVariants',
'ProductPhotos',
'PrimaryProductPhotos',
];
$associations = $this->ProductCategories->associations();
public function testInitialize(): void {
// verify all associations loaded
$expectedAssociations = [
'ProductCatalogs',
'ParentProductCategories',
'ChildProductCategories',
'Products',
'ProductCategoryAttributes',
'ProductCategoryVariants',
'ProductPhotos',
'PrimaryProductPhotos',
];
$associations = $this->ProductCategories->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCategories->hasAssociation($expectedAssociation));
}
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCategories->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [
'Tree',
'Trash',
];
$behaviors = $this->ProductCategories->behaviors();
// verify all behaviors loaded
$expectedBehaviors = [
'Tree',
'Trash',
];
$behaviors = $this->ProductCategories->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCategories->hasBehavior($expectedBehavior));
}
}
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCategories->hasBehavior($expectedBehavior));
}
}
/**
/**
* Test validationDefault method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductCategoriesTable::validationDefault()
* @return void
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
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
{
$this->markTestIncomplete('Not implemented yet.');
}
public function testBuildRules(): void {
$this->markTestIncomplete('Not implemented yet.');
}
}
@@ -11,98 +11,94 @@ 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;
protected $ProductCategoryAttributeOptions;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryAttributeOptions',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryAttributeOptions',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCategoryAttributeOptions') ? [] : ['className' => ProductCategoryAttributeOptionsTable::class];
$this->ProductCategoryAttributeOptions = $this->getTableLocator()->get('ProductCategoryAttributeOptions', $config);
}
protected function setUp(): void {
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCategoryAttributeOptions') ? [] : ['className' => ProductCategoryAttributeOptionsTable::class];
$this->ProductCategoryAttributeOptions = $this->getTableLocator()->get('ProductCategoryAttributeOptions', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCategoryAttributeOptions);
protected function tearDown(): void {
unset($this->ProductCategoryAttributeOptions);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* TestInitialize method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable::initialize
* @return void
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'ProductCategoryAttributes',
];
$associations = $this->ProductCategoryAttributeOptions->associations();
public function testInitialize(): void {
// verify all associations loaded
$expectedAssociations = [
'ProductCategoryAttributes',
];
$associations = $this->ProductCategoryAttributeOptions->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCategoryAttributeOptions->hasAssociation($expectedAssociation));
}
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCategoryAttributeOptions->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [
'Trash',
];
$behaviors = $this->ProductCategoryAttributeOptions->behaviors();
// verify all behaviors loaded
$expectedBehaviors = [
'Trash',
];
$behaviors = $this->ProductCategoryAttributeOptions->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCategoryAttributeOptions->hasBehavior($expectedBehavior));
}
}
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCategoryAttributeOptions->hasBehavior($expectedBehavior));
}
}
/**
/**
* Test validationDefault method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable::validationDefault
* @return void
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
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
{
$this->markTestIncomplete('Not implemented yet.');
}
public function testBuildRules(): void {
$this->markTestIncomplete('Not implemented yet.');
}
}
@@ -11,101 +11,97 @@ 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;
protected $ProductCategoryAttributes;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryAttributes',
'plugin.CakeProducts.ProductCategoryAttributeOptions',
'plugin.CakeProducts.ProductCategories',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryAttributes',
'plugin.CakeProducts.ProductCategoryAttributeOptions',
'plugin.CakeProducts.ProductCategories',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCategoryAttributes') ? [] : ['className' => ProductCategoryAttributesTable::class];
$this->ProductCategoryAttributes = $this->getTableLocator()->get('ProductCategoryAttributes', $config);
}
protected function setUp(): void {
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCategoryAttributes') ? [] : ['className' => ProductCategoryAttributesTable::class];
$this->ProductCategoryAttributes = $this->getTableLocator()->get('ProductCategoryAttributes', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCategoryAttributes);
protected function tearDown(): void {
unset($this->ProductCategoryAttributes);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* TestInitialize method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductCategoryAttributesTable::initialize
* @return void
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'ProductCategories',
'ProductCategoryAttributeOptions',
];
$associations = $this->ProductCategoryAttributes->associations();
public function testInitialize(): void {
// verify all associations loaded
$expectedAssociations = [
'ProductCategories',
'ProductCategoryAttributeOptions',
];
$associations = $this->ProductCategoryAttributes->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCategoryAttributes->hasAssociation($expectedAssociation));
}
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCategoryAttributes->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [
'Trash',
];
$behaviors = $this->ProductCategoryAttributes->behaviors();
// verify all behaviors loaded
$expectedBehaviors = [
'Trash',
];
$behaviors = $this->ProductCategoryAttributes->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCategoryAttributes->hasBehavior($expectedBehavior));
}
}
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCategoryAttributes->hasBehavior($expectedBehavior));
}
}
/**
/**
* Test validationDefault method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductCategoryAttributesTable::validationDefault
* @return void
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
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
{
$this->markTestIncomplete('Not implemented yet.');
}
public function testBuildRules(): void {
$this->markTestIncomplete('Not implemented yet.');
}
}
@@ -3,107 +3,103 @@ 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
*
* @var \App\Model\Table\ProductCategoryVariantOptionsTable
*/
protected $ProductCategoryVariantOptions;
protected $ProductCategoryVariantOptions;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryVariants',
'plugin.CakeProducts.ProductCategoryVariantOptions',
];
protected array $fixtures = [
'plugin.CakeProducts.ProductCategoryVariants',
'plugin.CakeProducts.ProductCategoryVariantOptions',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCategoryVariantOptions') ? [] : ['className' => ProductCategoryVariantOptionsTable::class];
$this->ProductCategoryVariantOptions = $this->getTableLocator()->get('ProductCategoryVariantOptions', $config);
}
protected function setUp(): void {
parent::setUp();
$config = $this->getTableLocator()->exists('ProductCategoryVariantOptions') ? [] : ['className' => ProductCategoryVariantOptionsTable::class];
$this->ProductCategoryVariantOptions = $this->getTableLocator()->get('ProductCategoryVariantOptions', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductCategoryVariantOptions);
protected function tearDown(): void {
unset($this->ProductCategoryVariantOptions);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* TestInitialize method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductCategoryVariantOptionsTable::initialize()
* @return void
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'ProductCategoryVariants',
];
$associations = $this->ProductCategoryVariantOptions->associations();
public function testInitialize(): void {
// verify all associations loaded
$expectedAssociations = [
'ProductCategoryVariants',
];
$associations = $this->ProductCategoryVariantOptions->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCategoryVariantOptions->hasAssociation($expectedAssociation));
}
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductCategoryVariantOptions->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [
'Timestamp',
];
$behaviors = $this->ProductCategoryVariantOptions->behaviors();
// verify all behaviors loaded
$expectedBehaviors = [
'Timestamp',
];
$behaviors = $this->ProductCategoryVariantOptions->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCategoryVariantOptions->hasBehavior($expectedBehavior));
}
}
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductCategoryVariantOptions->hasBehavior($expectedBehavior));
}
}
/**
/**
* Test validationDefault method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductCategoryVariantOptionsTable::validationDefault()
* @return void
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
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
{
$this->markTestIncomplete('Not implemented yet.');
}
public function testBuildRules(): void {
$this->markTestIncomplete('Not implemented yet.');
}
}
@@ -3,105 +3,101 @@ 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
*
* @var \App\Model\Table\ProductVariantsTable
*/
protected $ProductVariants;
protected $ProductVariants;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductCategoryVariants',
'plugin.CakeProducts.ProductCategoryVariantOptions',
];
protected array $fixtures = [
'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductCategoryVariants',
'plugin.CakeProducts.ProductCategoryVariantOptions',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('ProductVariants') ? [] : ['className' => ProductVariantsTable::class];
$this->ProductVariants = $this->getTableLocator()->get('ProductVariants', $config);
}
protected function setUp(): void {
parent::setUp();
$config = $this->getTableLocator()->exists('ProductVariants') ? [] : ['className' => ProductVariantsTable::class];
$this->ProductVariants = $this->getTableLocator()->get('ProductVariants', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ProductVariants);
protected function tearDown(): void {
unset($this->ProductVariants);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* TestInitialize method
*
* @return void
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'Products',
'ProductCategoryVariants',
'ProductSkuVariantValues',
];
$associations = $this->ProductVariants->associations();
public function testInitialize(): void {
// verify all associations loaded
$expectedAssociations = [
'Products',
'ProductCategoryVariants',
'ProductSkuVariantValues',
];
$associations = $this->ProductVariants->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductVariants->hasAssociation($expectedAssociation));
}
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ProductVariants->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [];
$behaviors = $this->ProductVariants->behaviors();
// verify all behaviors loaded
$expectedBehaviors = [];
$behaviors = $this->ProductVariants->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductVariants->hasBehavior($expectedBehavior));
}
}
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ProductVariants->hasBehavior($expectedBehavior));
}
}
/**
/**
* Test validationDefault method
*
* @return void
* @uses \App\Model\Table\ProductVariantsTable::validationDefault()
* @return void
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
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
{
$this->markTestIncomplete('Not implemented yet.');
}
public function testBuildRules(): void {
$this->markTestIncomplete('Not implemented yet.');
}
}
@@ -11,107 +11,103 @@ use PHPUnit\Framework\Attributes\CoversClass;
* CakeProducts\Model\Table\ProductsTable Test Case
*/
#[CoversClass(ProductsTable::class)]
class ProductsTableTest extends TestCase
{
/**
class ProductsTableTest extends TestCase {
/**
* Test subject
*
* @var ProductsTable
* @var \CakeProducts\Model\Table\ProductsTable
*/
protected $Products;
protected $Products;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductCategories',
'plugin.CakeProducts.ProductSkus',
'plugin.CakeProducts.ProductSkuVariantValues',
];
protected array $fixtures = [
'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductCategories',
'plugin.CakeProducts.ProductSkus',
'plugin.CakeProducts.ProductSkuVariantValues',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('Products') ? [] : ['className' => ProductsTable::class];
$this->Products = $this->getTableLocator()->get('Products', $config);
}
protected function setUp(): void {
parent::setUp();
$config = $this->getTableLocator()->exists('Products') ? [] : ['className' => ProductsTable::class];
$this->Products = $this->getTableLocator()->get('Products', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Products);
protected function tearDown(): void {
unset($this->Products);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* TestInitialize method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductsTable::initialize
* @return void
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'ProductCategories',
'ProductAttributes',
'ProductVariants',
'ProductSkus',
'ProductPhotos',
'PrimaryProductPhotos',
'DefaultProductSkus',
];
$associations = $this->Products->associations();
public function testInitialize(): void {
// verify all associations loaded
$expectedAssociations = [
'ProductCategories',
'ProductAttributes',
'ProductVariants',
'ProductSkus',
'ProductPhotos',
'PrimaryProductPhotos',
'DefaultProductSkus',
];
$associations = $this->Products->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->Products->hasAssociation($expectedAssociation));
}
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->Products->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [
'Trash',
];
$behaviors = $this->Products->behaviors();
// verify all behaviors loaded
$expectedBehaviors = [
'Trash',
];
$behaviors = $this->Products->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->Products->hasBehavior($expectedBehavior));
}
}
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->Products->hasBehavior($expectedBehavior));
}
}
/**
/**
* Test validationDefault method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductsTable::validationDefault
* @return void
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
public function testValidationDefault(): void {
$this->markTestIncomplete('Not implemented yet.');
}
/**
/**
* Test buildRules method
*
* @return void
* @uses \CakeProducts\Model\Table\ProductsTable::buildRules
* @return void
*/
public function testBuildRules(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
public function testBuildRules(): void {
$this->markTestIncomplete('Not implemented yet.');
}
}
+51 -52
View File
@@ -7,20 +7,19 @@ use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Database\Connection;
use Cake\Datasource\ConnectionManager;
use Cake\TestSuite\Fixture\SchemaLoader;
use CakeProducts\CakeProductsPlugin;
use Migrations\TestSuite\Migrator;
use TestApp\Controller\AppController;
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
define('DS', DIRECTORY_SEPARATOR);
}
if (!defined('WINDOWS')) {
if (DS === '\\' || substr(PHP_OS, 0, 3) === 'WIN') {
define('WINDOWS', true);
} else {
define('WINDOWS', false);
}
if (DS === '\\' || substr(PHP_OS, 0, 3) === 'WIN') {
define('WINDOWS', true);
} else {
define('WINDOWS', false);
}
}
define('PLUGIN_ROOT', dirname(__DIR__));
@@ -45,23 +44,23 @@ require CORE_PATH . 'config/bootstrap.php';
require CAKE . 'functions.php';
Configure::write('App', [
'namespace' => 'TestApp',
'encoding' => 'UTF-8',
'paths' => [
'testWebroot' => PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS,
'webroot' => PLUGIN_ROOT . DS . 'webroot' . DS,
'templates' => [
PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'templates' . DS,
],
],
'namespace' => 'TestApp',
'encoding' => 'UTF-8',
'paths' => [
'testWebroot' => PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS,
'webroot' => PLUGIN_ROOT . DS . 'webroot' . DS,
'templates' => [
PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'templates' . DS,
],
],
]);
Configure::write('debug', true);
Configure::write('CakeProducts', [
'photos' => [
'directory' => PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS . 'uploads' . DS . 'images' . DS . 'products' . DS,
],
/**
'photos' => [
'directory' => PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS . 'uploads' . DS . 'images' . DS . 'products' . DS,
],
/**
* internal CakeProducts settings - used in the source of truth/internal only system.
* Can optionally manage external catalogs
*
@@ -69,39 +68,39 @@ Configure::write('CakeProducts', [
* which will receive changes to the catalogs and optionally allow for external API access.
* Will have no effect if true but no external catalogs have been added or none are enabled
*/
'internal' => [
'enabled' => true,
/**
'internal' => [
'enabled' => true,
/**
* syncExternally defaults to false - product catalogs can have 1 or more external catalogs linked to them
* which will receive changes to the catalogs and optionally allow for external API access.
* Will have no effect if true but no external catalogs have been added or none are enabled
*/
'syncExternally' => false,
],
'external' => [ // product catalog settings for external use (as an API server to power an ecommerce site for example)
'enabled' => false,
],
'syncExternally' => false,
],
'external' => [ // product catalog settings for external use (as an API server to power an ecommerce site for example)
'enabled' => false,
],
]);
$cache = [
'default' => [
'engine' => 'File',
'path' => CACHE,
],
'_cake_translations_' => [
'className' => 'File',
'prefix' => 'crud_myapp_cake_core_',
'path' => CACHE . 'persistent/',
'serialize' => true,
'duration' => '+10 seconds',
],
'_cake_model_' => [
'className' => 'File',
'prefix' => 'crud_my_app_cake_model_',
'path' => CACHE . 'models/',
'serialize' => 'File',
'duration' => '+10 seconds',
],
'default' => [
'engine' => 'File',
'path' => CACHE,
],
'_cake_translations_' => [
'className' => 'File',
'prefix' => 'crud_myapp_cake_core_',
'path' => CACHE . 'persistent/',
'serialize' => true,
'duration' => '+10 seconds',
],
'_cake_model_' => [
'className' => 'File',
'prefix' => 'crud_my_app_cake_model_',
'path' => CACHE . 'models/',
'serialize' => 'File',
'duration' => '+10 seconds',
],
];
Cache::setConfig($cache);
@@ -113,15 +112,15 @@ Plugin::getCollection()->add(new CakeProductsPlugin());
Chronos::setTestNow(Chronos::now());
if (!getenv('DB_URL')) {
putenv('DB_URL=sqlite:///:memory:');
putenv('DB_URL=sqlite:///:memory:');
}
ConnectionManager::setConfig('test', [
'className' => Connection::class,
'url' => getenv('DB_URL') ?: null,
'timezone' => 'UTC',
'quoteIdentifiers' => false,
'cacheMetadata' => true,
'className' => Connection::class,
'url' => getenv('DB_URL') ?: null,
'timezone' => 'UTC',
'quoteIdentifiers' => false,
'cacheMetadata' => true,
]);
/**
+1
View File
@@ -1,4 +1,5 @@
<?php
/**
* Based entirely off of dereuromark's plugins as I was having trouble getting fixtures to load
* after moving the plugins outside of an existing cakephp app's plugins folder