Fixed tests

This commit is contained in:
Jan Böhmer 2023-11-22 17:14:24 +01:00
parent c86694ab8f
commit 50069c7611
2 changed files with 15 additions and 1 deletions

View file

@ -24,12 +24,17 @@ declare(strict_types=1);
namespace App\Services\EntityMergers\Mergers; namespace App\Services\EntityMergers\Mergers;
/**
* @template T of object
*/
interface EntityMergerInterface interface EntityMergerInterface
{ {
/** /**
* Determines if this merger supports merging the other entity into the target entity. * Determines if this merger supports merging the other entity into the target entity.
* @param object $target * @param object $target
* @phpstan-param T $target
* @param object $other * @param object $other
* @phpstan-param T $other
* @param array $context * @param array $context
* @return bool True if this merger supports merging the other entity into the target entity, false otherwise * @return bool True if this merger supports merging the other entity into the target entity, false otherwise
*/ */
@ -39,8 +44,11 @@ interface EntityMergerInterface
* Merge the other entity into the target entity. * Merge the other entity into the target entity.
* The target entity will be modified and returned. * The target entity will be modified and returned.
* @param object $target * @param object $target
* @phpstan-param T $target
* @param object $other * @param object $other
* @phpstan-param T $other
* @param array $context * @param array $context
* @phpstan-return T
* @return object * @return object
*/ */
public function merge(object $target, object $other, array $context = []): object; public function merge(object $target, object $other, array $context = []): object;

View file

@ -31,6 +31,9 @@ use App\Entity\Parts\PartLot;
use App\Entity\PriceInformations\Orderdetail; use App\Entity\PriceInformations\Orderdetail;
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
/**
* @implements EntityMergerInterface<Part>
*/
#[Autoconfigure(public: true)] #[Autoconfigure(public: true)]
class PartMerger implements EntityMergerInterface class PartMerger implements EntityMergerInterface
{ {
@ -74,7 +77,7 @@ class PartMerger implements EntityMergerInterface
$this->mergeTags($target, $other, 'tags'); $this->mergeTags($target, $other, 'tags');
//Merge manufacturing status //Merge manufacturing status
$this->useCallback(function (?ManufacturingStatus $t, ?ManufacturingStatus $o): ?ManufacturingStatus { $this->useCallback(function (?ManufacturingStatus $t, ?ManufacturingStatus $o): ManufacturingStatus {
//Use the other value, if the target value is not set //Use the other value, if the target value is not set
if ($t === ManufacturingStatus::NOT_SET || $t === null) { if ($t === ManufacturingStatus::NOT_SET || $t === null) {
return $o ?? ManufacturingStatus::NOT_SET; return $o ?? ManufacturingStatus::NOT_SET;
@ -91,6 +94,9 @@ class PartMerger implements EntityMergerInterface
return $t; return $t;
}, $target, $other, 'providerReference'); }, $target, $other, 'providerReference');
//Merge the collections
$this->mergeCollectionFields($target, $other, $context);
return $target; return $target;
} }