From c62253a8ccd7d10bdea0dd396c8ea9b1edef42c7 Mon Sep 17 00:00:00 2001 From: Patrick Gugelsberger Date: Fri, 17 May 2024 15:34:42 +0200 Subject: [PATCH 1/3] add missing factories --- .../CategoryCustomerGroupFactory.php | 35 +++++++++++++++++ src/Model/Generator/CategoryFactory.php | 6 +-- .../Generator/CategoryInvisibilityFactory.php | 33 ++++++++++++++++ src/Model/Generator/ChecksumFactory.php | 37 ++++++++++++++++++ src/Model/Generator/CustomerGroupFactory.php | 39 +++++++++++++++++++ .../Generator/CustomerGroupI18nFactory.php | 33 ++++++++++++++++ .../CustomerGroupPackagingQuantityFactory.php | 35 +++++++++++++++++ src/Model/Generator/PartsListFactory.php | 34 ++++++++++++++++ .../Generator/ProductConfigGroupFactory.php | 34 ++++++++++++++++ src/Model/Generator/ProductFactory.php | 15 +++---- .../Generator/ProductInvisibilityFactory.php | 33 ++++++++++++++++ .../Generator/ProductWarehouseInfoFactory.php | 35 +++++++++++++++++ 12 files changed, 359 insertions(+), 10 deletions(-) create mode 100644 src/Model/Generator/CategoryCustomerGroupFactory.php create mode 100644 src/Model/Generator/CategoryInvisibilityFactory.php create mode 100644 src/Model/Generator/ChecksumFactory.php create mode 100644 src/Model/Generator/CustomerGroupFactory.php create mode 100644 src/Model/Generator/CustomerGroupI18nFactory.php create mode 100644 src/Model/Generator/CustomerGroupPackagingQuantityFactory.php create mode 100644 src/Model/Generator/PartsListFactory.php create mode 100644 src/Model/Generator/ProductConfigGroupFactory.php create mode 100644 src/Model/Generator/ProductInvisibilityFactory.php create mode 100644 src/Model/Generator/ProductWarehouseInfoFactory.php diff --git a/src/Model/Generator/CategoryCustomerGroupFactory.php b/src/Model/Generator/CategoryCustomerGroupFactory.php new file mode 100644 index 00000000..84285374 --- /dev/null +++ b/src/Model/Generator/CategoryCustomerGroupFactory.php @@ -0,0 +1,35 @@ + + * @throws \Exception + */ + protected function makeFakeArray(): array + { + return [ + 'customerGroupId' => $this->getFactory('Identity')->makeOneArray(), + 'discount' => $this->faker->randomFloat(2, 0, 10) + ]; + } + + /** + * @return string + */ + protected function getModelClass(): string + { + return CategoryCustomerGroup::class; + } +} diff --git a/src/Model/Generator/CategoryFactory.php b/src/Model/Generator/CategoryFactory.php index 74072f7a..1255c153 100755 --- a/src/Model/Generator/CategoryFactory.php +++ b/src/Model/Generator/CategoryFactory.php @@ -27,9 +27,9 @@ protected function makeFakeArray(): array 'sort' => $this->faker->numberBetween(0, 10), 'id' => $identityFactory->makeOneArray(), 'isActive' => $this->faker->boolean, - 'attributes' => [], - 'customerGroups' => [], - 'invisibilities' => [], + 'attributes' => $this->getFactory('TranslatableAttribute')->makeArray(\random_int(1, 3)), + 'customerGroups' => $this->getFactory('CategoryCustomerGroup')->makeArray(\random_int(1, 3)), + 'invisibilities' => $this->getFactory('CategoryInvisibility')->makeArray(\random_int(1, 3)), 'i18ns' => $this->getFactory('CategoryI18n')->makeArray(\random_int(1, 3)), ]; } diff --git a/src/Model/Generator/CategoryInvisibilityFactory.php b/src/Model/Generator/CategoryInvisibilityFactory.php new file mode 100644 index 00000000..df6b5787 --- /dev/null +++ b/src/Model/Generator/CategoryInvisibilityFactory.php @@ -0,0 +1,33 @@ + + */ + protected function makeFakeArray(): array + { + return [ + 'customerGroupId' => $this->getFactory('Identity')->makeOneArray() + ]; + } + + /** + * @return string + */ + protected function getModelClass(): string + { + return CategoryInvisibility::class; + } +} diff --git a/src/Model/Generator/ChecksumFactory.php b/src/Model/Generator/ChecksumFactory.php new file mode 100644 index 00000000..6c9846bc --- /dev/null +++ b/src/Model/Generator/ChecksumFactory.php @@ -0,0 +1,37 @@ + + */ + protected function makeFakeArray(): array + { + return [ + 'foreignKey' => $this->getFactory('Identity')->makeOneArray(), + 'endpoint' => $this->faker->uuid, + 'hasChanged' => false, + 'host' => (string)$this->faker->numberBetween(1), + 'type' => Checksum::TYPE_VARIATION + ]; + } + + /** + * @return string + */ + protected function getModelClass(): string + { + return Checksum::class; + } +} diff --git a/src/Model/Generator/CustomerGroupFactory.php b/src/Model/Generator/CustomerGroupFactory.php new file mode 100644 index 00000000..aea65dae --- /dev/null +++ b/src/Model/Generator/CustomerGroupFactory.php @@ -0,0 +1,39 @@ + + * @throws \Exception + */ + protected function makeFakeArray(): array + { + return [ + 'id' => $this->getFactory('Identity')->makeOneArray(), + 'applyNetPrice' => $this->faker->boolean, + 'discount' => $this->faker->randomFloat(2, 0, 10), + 'isDefault' => $this->faker->boolean, + 'attributes' => $this->getFactory('TranslatableAttribute')->makeArray(\random_int(1, 3)), + 'i18ns' => $this->getFactory('CustomerGroupI18n')->makeArray(\random_int(1, 3)) + ]; + } + + /** + * @return string + */ + protected function getModelClass(): string + { + return CustomerGroup::class; + } +} diff --git a/src/Model/Generator/CustomerGroupI18nFactory.php b/src/Model/Generator/CustomerGroupI18nFactory.php new file mode 100644 index 00000000..fee32aed --- /dev/null +++ b/src/Model/Generator/CustomerGroupI18nFactory.php @@ -0,0 +1,33 @@ + + */ + protected function makeFakeArray(): array + { + return [ + 'name' => $this->faker->name + ]; + } + + /** + * @return string + */ + protected function getModelClass(): string + { + return CustomerGroupI18n::class; + } +} diff --git a/src/Model/Generator/CustomerGroupPackagingQuantityFactory.php b/src/Model/Generator/CustomerGroupPackagingQuantityFactory.php new file mode 100644 index 00000000..585655f2 --- /dev/null +++ b/src/Model/Generator/CustomerGroupPackagingQuantityFactory.php @@ -0,0 +1,35 @@ + + */ + protected function makeFakeArray(): array + { + return [ + 'customerGroupId' => $this->getFactory('Identity')->makeOneArray(), + 'minimumOrderQuantity' => $this->faker->numberBetween(1, 100), + 'packagingQuantity' => $this->faker->numberBetween(1, 100) + ]; + } + + /** + * @return string + */ + protected function getModelClass(): string + { + return CustomerGroupPackagingQuantity::class; + } +} diff --git a/src/Model/Generator/PartsListFactory.php b/src/Model/Generator/PartsListFactory.php new file mode 100644 index 00000000..9e92f1a8 --- /dev/null +++ b/src/Model/Generator/PartsListFactory.php @@ -0,0 +1,34 @@ + + */ + protected function makeFakeArray(): array + { + return [ + 'productId' => $this->getFactory('Identity')->makeOneArray(), + 'quantity' => $this->faker->numberBetween(1, 100) + ]; + } + + /** + * @return string + */ + protected function getModelClass(): string + { + return PartsList::class; + } +} diff --git a/src/Model/Generator/ProductConfigGroupFactory.php b/src/Model/Generator/ProductConfigGroupFactory.php new file mode 100644 index 00000000..c44bf09e --- /dev/null +++ b/src/Model/Generator/ProductConfigGroupFactory.php @@ -0,0 +1,34 @@ + + */ + protected function makeFakeArray(): array + { + return [ + 'configGroupId' => $this->getFactory('Identity')->makeOneArray(), + 'sort' => $this->faker->numberBetween(1, 10) + ]; + } + + /** + * @return string + */ + protected function getModelClass(): string + { + return ProductConfigGroup::class; + } +} diff --git a/src/Model/Generator/ProductFactory.php b/src/Model/Generator/ProductFactory.php index 0ccf6d2b..14596b33 100755 --- a/src/Model/Generator/ProductFactory.php +++ b/src/Model/Generator/ProductFactory.php @@ -211,16 +211,17 @@ protected function makeFakeArray(): array 'upc' => $this->faker->uuid, 'vat' => $taxRates[\random_int(0, $taxRatesMaxCount)]['rate'], 'width' => $this->faker->randomFloat(2), - 'attributes' => [], + 'attributes' => $this->getFactory('TranslatableAttribute')->makeArray(\random_int(1, 3)), 'categories' => $this->getFactory('Product2Category')->makeArray(\random_int(1, 3)), - 'checksums' => [], - //'configGroups' => [], - //'customerGroupPackagingQuantities' => [], + 'checksums' => $this->getFactory('Checksum')->makeArray(\random_int(1, 3)), + 'configGroups' => $this->getFactory('ProductConfigGroup')->makeArray(\random_int(1, 3)), + 'customerGroupPackagingQuantities' => $this->getFactory('CustomerGroupPackagingQuantity') + ->makeArray(\random_int(1, 3)), //'fileDownloads' => [], 'i18ns' => [$this->getFactory('ProductI18n')->makeOneArray()], - 'invisibilities' => [], + 'invisibilities' => $this->getFactory('ProductInvisibility')->makeArray(\random_int(1, 3)), 'mediaFiles' => [], - 'partsLists' => [], + 'partsLists' => $this->getFactory('PartsList')->makeArray(\random_int(1, 3)), 'prices' => [ $productPriceFactory ->setWithBulkPrices(\random_int(0, 1) === 1) @@ -230,7 +231,7 @@ protected function makeFakeArray(): array 'specifics' => [], 'taxRates' => $taxRates, 'variations' => [], - //'warehouseInfo' => [], + 'warehouseInfo' => $this->getFactory('ProductWarehouseInfo')->makeArray(\random_int(1, 3)), ]; } diff --git a/src/Model/Generator/ProductInvisibilityFactory.php b/src/Model/Generator/ProductInvisibilityFactory.php new file mode 100644 index 00000000..35a51c5a --- /dev/null +++ b/src/Model/Generator/ProductInvisibilityFactory.php @@ -0,0 +1,33 @@ + + */ + protected function makeFakeArray(): array + { + return [ + 'customerGroupId' => $this->getFactory('Identity')->makeOneArray(), + ]; + } + + /** + * @return string + */ + protected function getModelClass(): string + { + return ProductInvisibility::class; + } +} diff --git a/src/Model/Generator/ProductWarehouseInfoFactory.php b/src/Model/Generator/ProductWarehouseInfoFactory.php new file mode 100644 index 00000000..fef34607 --- /dev/null +++ b/src/Model/Generator/ProductWarehouseInfoFactory.php @@ -0,0 +1,35 @@ + + */ + protected function makeFakeArray(): array + { + return [ + 'warehouseId' => $this->getFactory('Identity')->makeOneArray(), + 'inflowQuantity' => $this->faker->randomNumber(1, 100), + 'stocklevel' => $this->faker->randomNumber(1, 100) + ]; + } + + /** + * @return string + */ + protected function getModelClass(): string + { + return ProductWarehouseInfo::class; + } +} From 27a5936aafdb45b0e449589d961cc15c3830e3c0 Mon Sep 17 00:00:00 2001 From: Patrick Gugelsberger Date: Fri, 17 May 2024 15:37:46 +0200 Subject: [PATCH 2/3] fix ProductWarehouseInfoFactory --- src/Model/Generator/ProductWarehouseInfoFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/Generator/ProductWarehouseInfoFactory.php b/src/Model/Generator/ProductWarehouseInfoFactory.php index fef34607..cc476bb9 100644 --- a/src/Model/Generator/ProductWarehouseInfoFactory.php +++ b/src/Model/Generator/ProductWarehouseInfoFactory.php @@ -20,8 +20,8 @@ protected function makeFakeArray(): array { return [ 'warehouseId' => $this->getFactory('Identity')->makeOneArray(), - 'inflowQuantity' => $this->faker->randomNumber(1, 100), - 'stocklevel' => $this->faker->randomNumber(1, 100) + 'inflowQuantity' => $this->faker->numberBetween(1, 100), + 'stocklevel' => $this->faker->numberBetween(1, 100) ]; } From 0b60a00e1c91f8ebe8d741b7d774de96265e4ba5 Mon Sep 17 00:00:00 2001 From: Patrick Gugelsberger Date: Mon, 17 Jun 2024 13:54:29 +0200 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1bd811c..3457b593 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ unreleased ----- - CO-2544 prevent zip bomb upload during image push +- CO-2601 add missing factories 5.2.12 -----