Run rector to refactor tests to PHPUnit ^11

This commit is contained in:
Grzegorz Sadowski 2025-06-03 21:54:31 +02:00
parent c960c7f6ed
commit 4ba69fa431
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
30 changed files with 205 additions and 210 deletions

View file

@ -10,6 +10,6 @@ return RectorConfig::configure()
->withImportNames(importShortClasses: false, removeUnusedImports: true)
->withSets([
LevelSetList::UP_TO_PHP_82,
PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::PHPUNIT_110,
])
;

View file

@ -119,24 +119,20 @@ final class SessionManagerTest extends TestCase
$this->sharedStorage
->expects($this->exactly(2))
->method('has')
->willReturnCallback(function (string $key): bool {
return match ($key) {
'behat_previous_session_name' => true,
'behat_previous_session_token_previous_session' => true,
default => throw new \UnhandledMatchError(),
};
->willReturnCallback(fn(string $key): bool => match ($key) {
'behat_previous_session_name' => true,
'behat_previous_session_token_previous_session' => true,
default => throw new \UnhandledMatchError(),
})
;
$this->sharedStorage
->expects($this->exactly(2))
->method('get')
->willReturnCallback(function (string $key) use ($token): mixed {
return match ($key) {
'behat_previous_session_name' => 'previous_session',
'behat_previous_session_token_previous_session' => $token,
default => throw new \UnhandledMatchError(),
};
->willReturnCallback(fn(string $key): mixed => match ($key) {
'behat_previous_session_name' => 'previous_session',
'behat_previous_session_token_previous_session' => $token,
default => throw new \UnhandledMatchError(),
})
;

View file

@ -77,12 +77,9 @@ final class BuildAddressFormSubscriberTest extends TestCase
$this->formFactory
->expects($this->once())
->method('createNamed')
->with('provinceCode', ProvinceCodeChoiceType::class, 'province', $this->callback(function (array $options) use ($country) {
return is_array($options) &&
isset($options['country']) &&
$options['country'] === $country
;
}))
->with('provinceCode', ProvinceCodeChoiceType::class, 'province', $this->callback(fn(array $options) => is_array($options) &&
isset($options['country']) &&
$options['country'] === $country))
->willReturn($provinceForm)
;
$form->expects($this->once())->method('add')->with($provinceForm)->willReturn($form);
@ -133,12 +130,9 @@ final class BuildAddressFormSubscriberTest extends TestCase
$this->formFactory
->expects($this->once())
->method('createNamed')
->with('provinceCode', ProvinceCodeChoiceType::class, null, $this->callback(function (array $options) use ($country) {
return is_array($options) &&
isset($options['country']) &&
$options['country'] === $country
;
}))
->with('provinceCode', ProvinceCodeChoiceType::class, null, $this->callback(fn(array $options) => is_array($options) &&
isset($options['country']) &&
$options['country'] === $country))
->willReturn($provinceForm)
;
$form->expects($this->once())->method('add')->with($provinceForm)->willReturn($form);

View file

@ -29,5 +29,5 @@ if (is_array($env = @include $envLocalPhpPath)) {
}
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_DEBUG'] ??= $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0';

View file

@ -11,48 +11,92 @@
declare(strict_types=1);
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle;
use Sylius\Bundle\OrderBundle\SyliusOrderBundle;
use Sylius\Bundle\MoneyBundle\SyliusMoneyBundle;
use Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle;
use Sylius\Bundle\LocaleBundle\SyliusLocaleBundle;
use Sylius\Bundle\ProductBundle\SyliusProductBundle;
use Sylius\Bundle\ChannelBundle\SyliusChannelBundle;
use Sylius\Bundle\AttributeBundle\SyliusAttributeBundle;
use Sylius\Bundle\TaxationBundle\SyliusTaxationBundle;
use Sylius\Bundle\ShippingBundle\SyliusShippingBundle;
use Sylius\Bundle\PaymentBundle\SyliusPaymentBundle;
use Sylius\Bundle\MailerBundle\SyliusMailerBundle;
use Sylius\Bundle\PromotionBundle\SyliusPromotionBundle;
use Sylius\Bundle\AddressingBundle\SyliusAddressingBundle;
use Sylius\Bundle\InventoryBundle\SyliusInventoryBundle;
use Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle;
use Sylius\Bundle\UserBundle\SyliusUserBundle;
use Sylius\Bundle\CustomerBundle\SyliusCustomerBundle;
use Sylius\Bundle\ReviewBundle\SyliusReviewBundle;
use Sylius\Bundle\CoreBundle\SyliusCoreBundle;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Sylius\Bundle\GridBundle\SyliusGridBundle;
use Knp\Bundle\GaufretteBundle\KnpGaufretteBundle;
use League\FlysystemBundle\FlysystemBundle;
use Liip\ImagineBundle\LiipImagineBundle;
use Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle;
use BabDev\PagerfantaBundle\BabDevPagerfantaBundle;
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
use Payum\Bundle\PayumBundle\PayumBundle;
use Sylius\Bundle\PayumBundle\SyliusPayumBundle;
use Sylius\Bundle\FixturesBundle\SyliusFixturesBundle;
use ApiPlatform\Symfony\Bundle\ApiPlatformBundle;
use Sylius\Bundle\ApiBundle\SyliusApiBundle;
use Symfony\Bundle\DebugBundle\DebugBundle;
use Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle;
use Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle;
use Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle;
use SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle;
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle;
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true],
Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true],
Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true],
Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true],
Sylius\Bundle\LocaleBundle\SyliusLocaleBundle::class => ['all' => true],
Sylius\Bundle\ProductBundle\SyliusProductBundle::class => ['all' => true],
Sylius\Bundle\ChannelBundle\SyliusChannelBundle::class => ['all' => true],
Sylius\Bundle\AttributeBundle\SyliusAttributeBundle::class => ['all' => true],
Sylius\Bundle\TaxationBundle\SyliusTaxationBundle::class => ['all' => true],
Sylius\Bundle\ShippingBundle\SyliusShippingBundle::class => ['all' => true],
Sylius\Bundle\PaymentBundle\SyliusPaymentBundle::class => ['all' => true],
Sylius\Bundle\MailerBundle\SyliusMailerBundle::class => ['all' => true],
Sylius\Bundle\PromotionBundle\SyliusPromotionBundle::class => ['all' => true],
Sylius\Bundle\AddressingBundle\SyliusAddressingBundle::class => ['all' => true],
Sylius\Bundle\InventoryBundle\SyliusInventoryBundle::class => ['all' => true],
Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle::class => ['all' => true],
Sylius\Bundle\UserBundle\SyliusUserBundle::class => ['all' => true],
Sylius\Bundle\CustomerBundle\SyliusCustomerBundle::class => ['all' => true],
Sylius\Bundle\ReviewBundle\SyliusReviewBundle::class => ['all' => true],
Sylius\Bundle\CoreBundle\SyliusCoreBundle::class => ['all' => true],
Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true],
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true],
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true],
Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true],
Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true],
ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
FrameworkBundle::class => ['all' => true],
SecurityBundle::class => ['all' => true],
TwigBundle::class => ['all' => true],
DoctrineBundle::class => ['all' => true],
SyliusStateMachineAbstractionBundle::class => ['all' => true],
SyliusOrderBundle::class => ['all' => true],
SyliusMoneyBundle::class => ['all' => true],
SyliusCurrencyBundle::class => ['all' => true],
SyliusLocaleBundle::class => ['all' => true],
SyliusProductBundle::class => ['all' => true],
SyliusChannelBundle::class => ['all' => true],
SyliusAttributeBundle::class => ['all' => true],
SyliusTaxationBundle::class => ['all' => true],
SyliusShippingBundle::class => ['all' => true],
SyliusPaymentBundle::class => ['all' => true],
SyliusMailerBundle::class => ['all' => true],
SyliusPromotionBundle::class => ['all' => true],
SyliusAddressingBundle::class => ['all' => true],
SyliusInventoryBundle::class => ['all' => true],
SyliusTaxonomyBundle::class => ['all' => true],
SyliusUserBundle::class => ['all' => true],
SyliusCustomerBundle::class => ['all' => true],
SyliusReviewBundle::class => ['all' => true],
SyliusCoreBundle::class => ['all' => true],
SyliusResourceBundle::class => ['all' => true],
SyliusGridBundle::class => ['all' => true],
KnpGaufretteBundle::class => ['all' => true],
FlysystemBundle::class => ['all' => true],
LiipImagineBundle::class => ['all' => true],
StofDoctrineExtensionsBundle::class => ['all' => true],
BabDevPagerfantaBundle::class => ['all' => true],
DoctrineMigrationsBundle::class => ['all' => true],
PayumBundle::class => ['all' => true],
SyliusPayumBundle::class => ['all' => true],
SyliusFixturesBundle::class => ['all' => true],
ApiPlatformBundle::class => ['all' => true],
SyliusApiBundle::class => ['all' => true],
DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
LexikJWTAuthenticationBundle::class => ['all' => true],
SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
WebpackEncoreBundle::class => ['all' => true],
];

View file

@ -24,7 +24,7 @@ if ($_SERVER['APP_DEBUG']) {
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
Request::setTrustedProxies(explode(',', (string) $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Application\Command;
final class FooCommand
final readonly class FooCommand
{
public function __construct(private string $bar)
{

View file

@ -94,10 +94,8 @@ final class FakeChannelPersisterTest extends TestCase
$this->responseHeaderBag
->expects(self::once())
->method('setCookie')
->with($this->callback(function (Cookie $cookie) {
return $cookie->getName() === '_channel_code' &&
$cookie->getValue() === 'fake_channel_code';
}));
->with($this->callback(fn(Cookie $cookie) => $cookie->getName() === '_channel_code' &&
$cookie->getValue() === 'fake_channel_code'));
$this->fakeChannelPersister->onKernelResponse(new ResponseEvent(
$this->kernelMock,

View file

@ -58,14 +58,12 @@ final class InForTaxonsScopeVariantCheckerTest extends TestCase
$this->taxonRepository
->method('findOneBy')
->willReturnCallback(function (array $criteria) use ($firstTaxon, $secondTaxon, $thirdTaxon, $fourthTaxon) {
return match ($criteria['code']) {
'FIRST_TAXON' => $firstTaxon,
'SECOND_TAXON' => $secondTaxon,
'THIRD_TAXON' => $thirdTaxon,
'FOURTH_TAXON' => $fourthTaxon,
default => null,
};
->willReturnCallback(fn(array $criteria) => match ($criteria['code']) {
'FIRST_TAXON' => $firstTaxon,
'SECOND_TAXON' => $secondTaxon,
'THIRD_TAXON' => $thirdTaxon,
'FOURTH_TAXON' => $fourthTaxon,
default => null,
});
$this->taxonTreeRepository->method('children')->willReturn([]);

View file

@ -75,9 +75,7 @@ final class CancelPaymentListenerTest extends TestCase
$this->stateMachine
->method('can')
->willReturnCallback(function ($payment) use ($payment1, $payment2) {
return in_array($payment, [$payment1, $payment2], true);
})
->willReturnCallback(fn($payment) => in_array($payment, [$payment1, $payment2], true))
;
$this->stateMachine

View file

@ -75,9 +75,7 @@ final class CancelShipmentListenerTest extends TestCase
$this->stateMachine
->method('can')
->willReturnCallback(function ($shipment) use ($shipment1, $shipment2) {
return in_array($shipment, [$shipment1, $shipment2], true);
})
->willReturnCallback(fn($shipment) => in_array($shipment, [$shipment1, $shipment2], true))
;
$this->stateMachine

View file

@ -61,9 +61,7 @@ final class AddBaseCurrencySubscriberTest extends TestCase
->with(
'baseCurrency',
$this->anything(),
$this->callback(function (array $options) {
return $options['disabled'] === true;
}),
$this->callback(fn(array $options) => $options['disabled'] === true),
)->willReturn($form)
;
@ -88,9 +86,7 @@ final class AddBaseCurrencySubscriberTest extends TestCase
->with(
'baseCurrency',
$this->anything(),
$this->callback(function (array $options) {
return $options['disabled'] === false;
}),
$this->callback(fn(array $options) => $options['disabled'] === false),
)->willReturn($form)
;
@ -114,9 +110,7 @@ final class AddBaseCurrencySubscriberTest extends TestCase
->with(
'baseCurrency',
$this->anything(),
$this->callback(function (array $options) {
return $options['disabled'] === false;
}),
$this->callback(fn(array $options) => $options['disabled'] === false),
)->willReturn($form)
;
@ -140,9 +134,7 @@ final class AddBaseCurrencySubscriberTest extends TestCase
->with(
'baseCurrency',
$this->anything(),
$this->callback(function (array $options) {
return $options['disabled'] === false;
}),
$this->callback(fn(array $options) => $options['disabled'] === false),
)->willReturn($form)
;

View file

@ -60,13 +60,11 @@ final class CommandExecutorTest extends TestCase
->expects($this->once())
->method('run')
->with(
$this->callback(function (ArrayInput $input) {
return $input->getFirstArgument() === 'command' &&
$input->getParameterOption('--no-debug') === true &&
$input->getParameterOption('--env') === 'dev' &&
$input->hasParameterOption('--verbose') &&
!$input->hasParameterOption('--no-interaction');
}),
$this->callback(fn(ArrayInput $input) => $input->getFirstArgument() === 'command' &&
$input->getParameterOption('--no-debug') === true &&
$input->getParameterOption('--env') === 'dev' &&
$input->hasParameterOption('--verbose') &&
!$input->hasParameterOption('--no-interaction')),
$this->isInstanceOf(NullOutput::class),
)
->willReturn(0)
@ -95,13 +93,11 @@ final class CommandExecutorTest extends TestCase
->expects($this->once())
->method('run')
->with(
$this->callback(function (ArrayInput $input) {
return $input->getFirstArgument() === 'command' &&
$input->getParameterOption('--no-debug') === true &&
$input->getParameterOption('--env') === 'dev' &&
$input->hasParameterOption('--verbose') &&
$input->hasParameterOption('--no-interaction');
}),
$this->callback(fn(ArrayInput $input) => $input->getFirstArgument() === 'command' &&
$input->getParameterOption('--no-debug') === true &&
$input->getParameterOption('--env') === 'dev' &&
$input->hasParameterOption('--verbose') &&
$input->hasParameterOption('--no-interaction')),
$this->isInstanceOf(NullOutput::class),
)
->willReturn(0)

View file

@ -71,13 +71,11 @@ final class BatchedApplyLowestPriceOnChannelPricingsCommandDispatcherTest extend
$this->channelPricingRepository
->method('findBy')
->willReturnCallback(function ($criteria, $orderBy, $limit, $offset) use ($cp1, $cp2, $cp3, $cp4, $cp5) {
return match ($offset) {
0 => [$cp1, $cp2],
2 => [$cp3, $cp4],
4 => [$cp5],
default => [],
};
->willReturnCallback(fn($criteria, $orderBy, $limit, $offset) => match ($offset) {
0 => [$cp1, $cp2],
2 => [$cp3, $cp4],
4 => [$cp5],
default => [],
})
;

View file

@ -131,10 +131,8 @@ final class ProductLowestPriceBeforeDiscountProcessorTest extends TestCase
$this->logEntryRepository
->expects($this->once())
->method('findLowestPriceInPeriod')
->with(1234, $channelPricing, $this->callback(function ($value) use ($expectedStartDate) {
return $value instanceof \DateTimeInterface &&
$value->format('Y-m-d') === $expectedStartDate->format('Y-m-d');
}))
->with(1234, $channelPricing, $this->callback(fn($value) => $value instanceof \DateTimeInterface &&
$value->format('Y-m-d') === $expectedStartDate->format('Y-m-d')))
->willReturn(6900)
;

View file

@ -13,6 +13,7 @@ declare(strict_types=1);
namespace Tests\Sylius\Bundle\CoreBundle\Validator\Constraints;
use Symfony\Component\Validator\ConstraintValidator;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Sylius\Bundle\CoreBundle\Validator\Constraints\UniqueReviewerEmail;
@ -57,7 +58,7 @@ final class UniqueReviewerEmailValidatorTest extends TestCase
public function testExtendsConstraintValidatorClass(): void
{
$this->assertInstanceOf(\Symfony\Component\Validator\ConstraintValidator::class, $this->validator);
$this->assertInstanceOf(ConstraintValidator::class, $this->validator);
}
public function testValidatesIfUserWithGivenEmailIsAlreadyRegistered(): void

View file

@ -82,12 +82,10 @@ final class CartChangesResetterTest extends TestCase
$unitOfWork
->expects(self::exactly(2))
->method('getEntityState')
->willReturnCallback(function ($unit) use ($unitNew, $unitExisting) {
return match ($unit) {
$unitNew => UnitOfWork::STATE_NEW,
$unitExisting => UnitOfWork::STATE_MANAGED,
default => throw new \UnhandledMatchError(),
};
->willReturnCallback(fn($unit) => match ($unit) {
$unitNew => UnitOfWork::STATE_NEW,
$unitExisting => UnitOfWork::STATE_MANAGED,
default => throw new \UnhandledMatchError(),
});
$item

View file

@ -94,9 +94,7 @@ final class PaymentRequestCancellerTest extends TestCase
$this->objectManager->expects(self::once())
->method('persist')
->with(self::callback(function ($object) use ($paymentRequest1) {
return $object === $paymentRequest1;
}));
->with(self::callback(fn($object) => $object === $paymentRequest1));
$this->objectManager->expects(self::once())
->method('flush');

View file

@ -177,9 +177,7 @@ final class NonChannelLocaleListenerTest extends TestCase
$event
->expects($this->once())
->method('setResponse')
->with($this->callback(function ($response) {
return $response instanceof RedirectResponse && $response->getTargetUrl() === '/ga/';
}))
->with($this->callback(fn($response) => $response instanceof RedirectResponse && $response->getTargetUrl() === '/ga/'))
;
$this->nonChannelLocaleListener->restrictRequestLocale($event);

View file

@ -47,6 +47,6 @@ final class ShopUserLogoutHandlerTest extends TestCase
$this->channelContext->expects($this->once())->method('getChannel')->willReturn($channel);
$this->cartStorage->expects($this->once())->method('removeForChannel')->with($channel);
$this->shopUserLogoutHandler->onLogout($logoutEvent);
$this->shopUserLogoutHandler->onLogout();
}
}

View file

@ -11,6 +11,12 @@
declare(strict_types=1);
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use BabDev\PagerfantaBundle\BabDevPagerfantaBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;
@ -19,12 +25,12 @@ class AppKernel extends Kernel
public function registerBundles(): iterable
{
return [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new BabDev\PagerfantaBundle\BabDevPagerfantaBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new FrameworkBundle(),
new BabDevPagerfantaBundle(),
new DoctrineBundle(),
new SyliusTaxonomyBundle(),
new SyliusResourceBundle(),
new TwigBundle(),
];
}

View file

@ -11,6 +11,14 @@
declare(strict_types=1);
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use BabDev\PagerfantaBundle\BabDevPagerfantaBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Sylius\Bundle\UserBundle\SyliusUserBundle;
use Sylius\Bundle\MailerBundle\SyliusMailerBundle;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;
@ -19,14 +27,14 @@ class AppKernel extends Kernel
public function registerBundles(): iterable
{
return [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new BabDev\PagerfantaBundle\BabDevPagerfantaBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sylius\Bundle\UserBundle\SyliusUserBundle(),
new Sylius\Bundle\MailerBundle\SyliusMailerBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new FrameworkBundle(),
new SecurityBundle(),
new BabDevPagerfantaBundle(),
new DoctrineBundle(),
new SyliusUserBundle(),
new SyliusMailerBundle(),
new SyliusResourceBundle(),
new TwigBundle(),
];
}

View file

@ -53,12 +53,10 @@ final class ZoneMatcherTest extends TestCase
$this->zoneRepositoryMock
->expects(self::exactly(2))
->method('findOneByAddressAndType')
->willReturnCallback(function (AddressInterface $address, string $type, ?string $scope = null) use ($addressMock, $zoneMock) {
return match ([$address, $type, $scope]) {
[$addressMock, ZoneInterface::TYPE_PROVINCE, null] => null,
[$addressMock, ZoneInterface::TYPE_COUNTRY, null] => $zoneMock,
default => throw new \UnhandledMatchError(),
};
->willReturnCallback(fn(AddressInterface $address, string $type, ?string $scope = null) => match ([$address, $type, $scope]) {
[$addressMock, ZoneInterface::TYPE_PROVINCE, null] => null,
[$addressMock, ZoneInterface::TYPE_COUNTRY, null] => $zoneMock,
default => throw new \UnhandledMatchError(),
});
self::assertSame($zoneMock, $this->zoneMatcher->match($addressMock));
}
@ -72,13 +70,11 @@ final class ZoneMatcherTest extends TestCase
$this->zoneRepositoryMock
->expects(self::exactly(3))
->method('findOneByAddressAndType')
->willReturnCallback(function (AddressInterface $address, string $type, ?string $scope = null) use ($addressMock, $zoneMock) {
return match ([$address, $type, $scope]) {
[$addressMock, ZoneInterface::TYPE_PROVINCE, null],
[$addressMock, ZoneInterface::TYPE_COUNTRY, null] => null,
[$addressMock, ZoneInterface::TYPE_ZONE, null] => $zoneMock,
default => throw new \UnhandledMatchError(),
};
->willReturnCallback(fn(AddressInterface $address, string $type, ?string $scope = null) => match ([$address, $type, $scope]) {
[$addressMock, ZoneInterface::TYPE_PROVINCE, null],
[$addressMock, ZoneInterface::TYPE_COUNTRY, null] => null,
[$addressMock, ZoneInterface::TYPE_ZONE, null] => $zoneMock,
default => throw new \UnhandledMatchError(),
});
self::assertSame($zoneMock, $this->zoneMatcher->match($addressMock));
}
@ -108,13 +104,11 @@ final class ZoneMatcherTest extends TestCase
$this->zoneRepositoryMock
->expects(self::exactly(3))
->method('findByMembers')
->willReturnCallback(function (array $members) use ($zoneOneMock, $zoneTwoMock, $zoneThreeMock) {
return match ($members) {
[$zoneOneMock] => [$zoneTwoMock],
[$zoneTwoMock] => [$zoneThreeMock],
[$zoneThreeMock] => [],
default => throw new \UnhandledMatchError(),
};
->willReturnCallback(fn(array $members) => match ($members) {
[$zoneOneMock] => [$zoneTwoMock],
[$zoneTwoMock] => [$zoneThreeMock],
[$zoneThreeMock] => [],
default => throw new \UnhandledMatchError(),
});
$matchedZones = $this->zoneMatcher->matchAll($addressMock);
self::assertCount(3, $matchedZones);
@ -138,13 +132,11 @@ final class ZoneMatcherTest extends TestCase
$this->zoneRepositoryMock
->expects(self::exactly(3))
->method('findByMembers')
->willReturnCallback(function (array $members) use ($zoneOneMock, $zoneTwoMock, $zoneThreeMock) {
return match ($members) {
[$zoneOneMock] => [$zoneTwoMock],
[$zoneTwoMock] => [$zoneThreeMock],
[$zoneThreeMock] => [],
default => throw new \UnhandledMatchError(),
};
->willReturnCallback(fn(array $members) => match ($members) {
[$zoneOneMock] => [$zoneTwoMock],
[$zoneTwoMock] => [$zoneThreeMock],
[$zoneThreeMock] => [],
default => throw new \UnhandledMatchError(),
});
$matchedZones = $this->zoneMatcher->matchAll($addressMock, 'shipping');
self::assertCount(2, $matchedZones);

View file

@ -146,7 +146,7 @@ final class CachedPerRequestChannelContextTest extends TestCase
$callable = new class($channel) {
private int $counter = 0;
public function __construct(private ChannelInterface $channel)
public function __construct(private readonly ChannelInterface $channel)
{
}

View file

@ -108,9 +108,7 @@ final class ShopBasedCartContextTest extends TestCase
$this->cart->expects($this->once())->method('setCustomer')->with($this->customer);
$this->cart->expects($this->once())
->method('setBillingAddress')
->with($this->callback(static function (AddressInterface $address): bool {
return $address->getCustomer() === null;
}));
->with($this->callback(static fn(AddressInterface $address): bool => $address->getCustomer() === null));
$this->assertSame($this->cart, $this->shopBasedCartContext->getCart());
}

View file

@ -737,17 +737,11 @@ final class OrderTest extends TestCase
$orderUnitAdjustmentForItem->expects($this->once())->method('getAmount')->willReturn(-20);
$orderUnitAdjustmentForItem->expects($this->once())->method('isNeutral')->willReturn(false);
$this->firstItem->expects($this->once())->method('getTotal')->willReturn(200);
$this->firstItem->expects($this->exactly(3))->method('getAdjustmentsRecursively')->willReturnCallback(function ($type) use (
$orderAdjustmentForItem,
$orderItemAdjustmentForItem,
$orderUnitAdjustmentForItem
) {
return match ($type) {
AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT => new ArrayCollection([$orderAdjustmentForItem]),
AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT => new ArrayCollection([$orderItemAdjustmentForItem]),
AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT => new ArrayCollection([$orderUnitAdjustmentForItem]),
default => new ArrayCollection(),
};
$this->firstItem->expects($this->exactly(3))->method('getAdjustmentsRecursively')->willReturnCallback(fn($type) => match ($type) {
AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT => new ArrayCollection([$orderAdjustmentForItem]),
AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT => new ArrayCollection([$orderItemAdjustmentForItem]),
AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT => new ArrayCollection([$orderUnitAdjustmentForItem]),
default => new ArrayCollection(),
});
$this->firstItem->expects($this->once())->method('setOrder')->with($this->order);
$this->order->addItem($this->firstItem);

View file

@ -139,7 +139,7 @@ final class SalesStatisticsProviderTest extends TestCase
$firstRegistry->method('getByType')->willReturn(new class($firstProvider) implements SalesProviderInterface {
/** @param array<array{period: \DateTimeImmutable, ...}> $data */
public function __construct(private array $data)
public function __construct(private readonly array $data)
{
}
@ -151,7 +151,7 @@ final class SalesStatisticsProviderTest extends TestCase
$secondRegistry->method('getByType')->willReturn(new class($secondProvider) implements SalesProviderInterface {
/** @param array<array{period: \DateTimeImmutable, ...}> $data */
public function __construct(private array $data)
public function __construct(private readonly array $data)
{
}

View file

@ -79,9 +79,7 @@ final class ImageUploaderTest extends TestCase
$this->image->method('getPath')->willReturnCallback(function () use (&$currentPath) {
return $currentPath;
});
$this->filesystem->method('has')->willReturnCallback(function ($path) {
return $path === 'foo.jpg';
});
$this->filesystem->method('has')->willReturnCallback(fn($path) => $path === 'foo.jpg');
$this->filesystem->expects($this->once())->method('delete')->with('foo.jpg');
$this->imagePathGenerator->expects($this->once())
->method('generate')

View file

@ -53,9 +53,7 @@ final class CachedLocaleCollectionProviderTest extends TestCase
$anotherLocale->method('getCode')->willReturn('en_GB');
$this->cache->expects($this->once())->method('get')
->with('sylius_locales', $this->isType('callable'))
->willReturnCallback(function (string $key, callable $callback) {
return $callback();
});
->willReturnCallback(fn(string $key, callable $callback) => $callback());
$this->decorated->expects($this->once())->method('getAll')
->willReturn(['en_US' => $someLocale, 'en_GB' => $anotherLocale]);
self::assertSame(['en_US' => $someLocale, 'en_GB' => $anotherLocale], $this->cachedLocaleCollectionProvider->getAll());

View file

@ -101,12 +101,8 @@ final class PromotionCouponGeneratorTest extends TestCase
$this->promotionCouponFactory->expects($this->once())->method('createNew')->willReturn($this->promotionCoupon);
$this->promotionCouponRepository->expects($this->once())->method('findOneBy')->willReturn(null);
$this->promotionCoupon->expects($this->once())->method('setPromotion')->with($this->promotion);
$this->promotionCoupon->expects($this->once())->method('setCode')->willReturnCallback(function (string $couponCode): bool {
return
str_starts_with($couponCode, 'PREFIX_') &&
strpos($couponCode, '_SUFFIX') === strlen($couponCode) - strlen('_SUFFIX')
;
});
$this->promotionCoupon->expects($this->once())->method('setCode')->willReturnCallback(fn(string $couponCode): bool => str_starts_with($couponCode, 'PREFIX_') &&
strpos($couponCode, '_SUFFIX') === strlen($couponCode) - strlen('_SUFFIX'));
$this->promotionCoupon->expects($this->once())->method('setUsageLimit')->with(null);
$this->promotionCoupon->expects($this->once())->method('setExpiresAt')->with(null);
$this->objectManager->expects($this->once())->method('persist')->with($this->promotionCoupon);