Skip to content

Commit

Permalink
Merge branch 'feature/CO-2601_add_missing_factories' into 'master'
Browse files Browse the repository at this point in the history
feature/CO-2601_add_missing_factories

See merge request connector/core!26
  • Loading branch information
Patrick-Gugelsberger committed Oct 31, 2024
2 parents 59daba1 + c8869fc commit 9b808cd
Show file tree
Hide file tree
Showing 13 changed files with 360 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ unreleased
-----
- CO-2544 prevent zip bomb upload during image push
- CO-2177 add support for warning messages in response
- CO-2601 add missing factories

5.2.12
-----
Expand Down
35 changes: 35 additions & 0 deletions src/Model/Generator/CategoryCustomerGroupFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Jtl\Connector\Core\Model\Generator;

use Jtl\Connector\Core\Model\CategoryCustomerGroup;

/**
* Class CategoryCustomerGroupFactory
*
* @package Jtl\Connector\Core\Model\Generator
*/
class CategoryCustomerGroupFactory extends AbstractModelFactory
{
/**
* @return array<string, mixed>
* @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;
}
}
6 changes: 3 additions & 3 deletions src/Model/Generator/CategoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
];
}
Expand Down
33 changes: 33 additions & 0 deletions src/Model/Generator/CategoryInvisibilityFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace Jtl\Connector\Core\Model\Generator;

use Jtl\Connector\Core\Model\CategoryInvisibility;

/**
* Class CategoryInvisibilityFactory
*
* @package Jtl\Connector\Core\Model\Generator
*/
class CategoryInvisibilityFactory extends AbstractModelFactory
{
/**
* @return array<string, mixed>
*/
protected function makeFakeArray(): array
{
return [
'customerGroupId' => $this->getFactory('Identity')->makeOneArray()
];
}

/**
* @return string
*/
protected function getModelClass(): string
{
return CategoryInvisibility::class;
}
}
37 changes: 37 additions & 0 deletions src/Model/Generator/ChecksumFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Jtl\Connector\Core\Model\Generator;

use Jtl\Connector\Core\Model\Checksum;

/**
* Class ChecksumFactory
*
* @package Jtl\Connector\Core\Model\Generator
*/
class ChecksumFactory extends AbstractModelFactory
{
/**
* @return array<string, mixed>
*/
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;
}
}
39 changes: 39 additions & 0 deletions src/Model/Generator/CustomerGroupFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Jtl\Connector\Core\Model\Generator;

use Jtl\Connector\Core\Model\CustomerGroup;

/**
* Class CustomerGroupFactory
*
* @package Jtl\Connector\Core\Model\Generator
*/
class CustomerGroupFactory extends AbstractModelFactory
{
/**
* @return array<string, mixed>
* @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;
}
}
33 changes: 33 additions & 0 deletions src/Model/Generator/CustomerGroupI18nFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace Jtl\Connector\Core\Model\Generator;

use Jtl\Connector\Core\Model\CustomerGroupI18n;

/**
* Class CustomerGroupI18nFactory
*
* @package Jtl\Connector\Core\Model\Generator
*/
class CustomerGroupI18nFactory extends AbstractModelFactory
{
/**
* @return array<string, string>
*/
protected function makeFakeArray(): array
{
return [
'name' => $this->faker->name
];
}

/**
* @return string
*/
protected function getModelClass(): string
{
return CustomerGroupI18n::class;
}
}
35 changes: 35 additions & 0 deletions src/Model/Generator/CustomerGroupPackagingQuantityFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Jtl\Connector\Core\Model\Generator;

use Jtl\Connector\Core\Model\CustomerGroupPackagingQuantity;

/**
* Class CustomerGroupPackagingQuantityFactory
*
* @package Jtl\Connector\Core\Model\Generator
*/
class CustomerGroupPackagingQuantityFactory extends AbstractModelFactory
{
/**
* @return array<string, mixed>
*/
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;
}
}
34 changes: 34 additions & 0 deletions src/Model/Generator/PartsListFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Jtl\Connector\Core\Model\Generator;

use Jtl\Connector\Core\Model\PartsList;

/**
* Class PartsListFactory
*
* @package Jtl\Connector\Core\Model\Generator
*/
class PartsListFactory extends AbstractModelFactory
{
/**
* @return array<string, mixed>
*/
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;
}
}
34 changes: 34 additions & 0 deletions src/Model/Generator/ProductConfigGroupFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Jtl\Connector\Core\Model\Generator;

use Jtl\Connector\Core\Model\ProductConfigGroup;

/**
* Class ProductConfigGroupFactory
*
* @package Jtl\Connector\Core\Model\Generator
*/
class ProductConfigGroupFactory extends AbstractModelFactory
{
/**
* @return array<string, mixed>
*/
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;
}
}
15 changes: 8 additions & 7 deletions src/Model/Generator/ProductFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,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)
Expand All @@ -229,7 +230,7 @@ protected function makeFakeArray(): array
'specifics' => [],
'taxRates' => $taxRates,
'variations' => [],
//'warehouseInfo' => [],
'warehouseInfo' => $this->getFactory('ProductWarehouseInfo')->makeArray(\random_int(1, 3)),
];
}

Expand Down
33 changes: 33 additions & 0 deletions src/Model/Generator/ProductInvisibilityFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace Jtl\Connector\Core\Model\Generator;

use Jtl\Connector\Core\Model\ProductInvisibility;

/**
* Class ProductInvisibilityFactory
*
* @package Jtl\Connector\Core\Model\Generator
*/
class ProductInvisibilityFactory extends AbstractModelFactory
{
/**
* @return array<string, mixed>
*/
protected function makeFakeArray(): array
{
return [
'customerGroupId' => $this->getFactory('Identity')->makeOneArray(),
];
}

/**
* @return string
*/
protected function getModelClass(): string
{
return ProductInvisibility::class;
}
}
Loading

0 comments on commit 9b808cd

Please sign in to comment.