mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[CS][DX] Refactor
This commit is contained in:
parent
416e16681e
commit
325d8976f7
8 changed files with 13 additions and 18 deletions
|
|
@ -18,7 +18,7 @@ use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
|||
|
||||
final class FlattenExceptionNormalizer implements ContextAwareNormalizerInterface
|
||||
{
|
||||
public function __construct (
|
||||
public function __construct(
|
||||
private ContextAwareNormalizerInterface $decorated,
|
||||
private RequestStack $requestStack,
|
||||
private string $newApiRoute,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|||
|
||||
final class HydraErrorNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
|
||||
{
|
||||
public function __construct (
|
||||
public function __construct(
|
||||
/** @var NormalizerInterface&CacheableSupportsMethodInterface */
|
||||
private NormalizerInterface $decorated,
|
||||
private RequestStack $requestStack,
|
||||
|
|
@ -48,7 +48,6 @@ final class HydraErrorNormalizer implements NormalizerInterface, CacheableSuppor
|
|||
return $this->decorated->supportsNormalization($data, $format);
|
||||
}
|
||||
|
||||
|
||||
public function hasCacheableSupportsMethod(): bool
|
||||
{
|
||||
return $this->decorated->hasCacheableSupportsMethod();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\ApiBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
|
||||
use Sylius\Bundle\ApiBundle\DependencyInjection\Compiler\FlattenExceptionNormalizerDecoratorCompilerPass;
|
||||
use Sylius\Bundle\ApiBundle\DependencyInjection\Compiler\LegacyErrorHandlingCompilerPass;
|
||||
use Sylius\Bundle\ApiBundle\Serializer\FlattenExceptionNormalizer;
|
||||
use Sylius\Bundle\ApiBundle\Serializer\HydraErrorNormalizer;
|
||||
|
|
|
|||
|
|
@ -45,17 +45,17 @@ final class PromotionCouponEligibilityValidator extends ConstraintValidator
|
|||
}
|
||||
|
||||
$promotionCoupon = $this->promotionCouponRepository->findOneBy(['code' => $value->couponCode]);
|
||||
|
||||
|
||||
if (!$promotionCoupon instanceof PromotionCouponInterface) {
|
||||
$this->context
|
||||
->buildViolation($constraint->message)
|
||||
->atPath('couponCode')
|
||||
->addViolation()
|
||||
;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** @var OrderInterface $cart */
|
||||
$cart = $this->orderRepository->findCartByTokenValue($value->getOrderTokenValue());
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ final class HydraErrorNormalizerSpec extends ObjectBehavior
|
|||
|
||||
function it_decorates_has_cacheable_supports_method(
|
||||
NormalizerInterface $normalizer,
|
||||
RequestStack $requestStack
|
||||
RequestStack $requestStack,
|
||||
): void {
|
||||
$normalizer->implement(CacheableSupportsMethodInterface::class);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,9 @@ final class ExpiredCartsRemoverSpec extends ObjectBehavior
|
|||
): void {
|
||||
$orderRepository->findCartsNotModifiedSince(Argument::type('\DateTimeInterface'), 100)->willReturn(
|
||||
[$firstCart, $secondCart],
|
||||
[]
|
||||
[],
|
||||
);
|
||||
|
||||
|
||||
$eventDispatcher
|
||||
->dispatch(Argument::any(), SyliusExpiredCartsEvents::PRE_REMOVE)
|
||||
->shouldBeCalled()
|
||||
|
|
@ -76,7 +75,7 @@ final class ExpiredCartsRemoverSpec extends ObjectBehavior
|
|||
->willReturn(
|
||||
array_fill(0, 100, $cart),
|
||||
array_fill(0, 100, $cart),
|
||||
[]
|
||||
[],
|
||||
)
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ class Order extends BaseOrder implements OrderInterface
|
|||
$shipment->removeUnit($unit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->shipments->clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,9 +138,8 @@ final class OrderSpec extends ObjectBehavior
|
|||
|
||||
function it_removes_shipments_with_units(
|
||||
ShipmentInterface $shipment,
|
||||
ShipmentUnitInterface $shipmentUnit
|
||||
): void
|
||||
{
|
||||
ShipmentUnitInterface $shipmentUnit,
|
||||
): void {
|
||||
$this->addShipment($shipment);
|
||||
$this->hasShipment($shipment)->shouldReturn(true);
|
||||
$shipment->getUnits()->willReturn(new ArrayCollection([$shipmentUnit->getWrappedObject()]));
|
||||
|
|
@ -153,9 +152,8 @@ final class OrderSpec extends ObjectBehavior
|
|||
|
||||
function it_removes_shipments_without_units(
|
||||
ShipmentInterface $shipment,
|
||||
ShipmentUnitInterface $shipmentUnit
|
||||
): void
|
||||
{
|
||||
ShipmentUnitInterface $shipmentUnit,
|
||||
): void {
|
||||
$this->addShipment($shipment);
|
||||
$this->hasShipment($shipment)->shouldReturn(true);
|
||||
$shipment->getUnits()->willReturn(new ArrayCollection([]));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue