diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2447d88..7a721d7f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,15 +18,9 @@ jobs: strategy: fail-fast: false matrix: - php: [7.4, 7.3] + php: [7.4] node: [10.x] - mysql: [5.7, 8.0] - - exclude: - - # PHP 7.3 does not support "caching_sha2_password" authentication plugin which is a default one in MySQL 8.0 - php: 7.3 - mysql: 8.0 - + mysql: [8.0] env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" diff --git a/composer.json b/composer.json index eaed9566..a1f2705a 100644 --- a/composer.json +++ b/composer.json @@ -4,11 +4,12 @@ "description": "Wishlist plugin for Sylius.", "license": "MIT", "require": { - "php": "^7.3", - "sylius/sylius": "^1.8" + "php": "^7.4", + "sylius/sylius": "^1.9", + "friendsofsymfony/oauth-server-bundle": ">2.0.0-alpha.0 ^2.0@dev" }, "require-dev": { - "behat/behat": "^3.6.1", + "behat/behat": "^3.7", "behat/mink-selenium2-driver": "^1.4", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", @@ -19,28 +20,28 @@ "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", - "lakion/mink-debug-extension": "^2.0.0", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.25", - "phpstan/phpstan-doctrine": "0.12.13", + "phpstan/phpstan": "0.12.80", + "phpstan/phpstan-doctrine": "0.12.32", "phpstan/phpstan-strict-rules": "^0.12.0", "phpstan/phpstan-webmozart-assert": "0.12.4", "phpunit/phpunit": "^9.5", - "sensiolabs/security-checker": "^6.0", "sylius-labs/coding-standard": "^3.1", - "symfony/browser-kit": "^4.4", - "symfony/debug-bundle": "^4.4|^5.0", - "symfony/dotenv": "^4.4|^5.0", - "symfony/intl": "^4.4|^5.0", - "symfony/web-profiler-bundle": "^4.4|^5.0", - "symfony/web-server-bundle": "^4.4|^5.0", - "vimeo/psalm": "4.3.1" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/debug-bundle": "^4.4 || ^5.2", + "symfony/dotenv": "^4.4 || ^5.2", + "symfony/intl": "^4.4 || ^5.2", + "symfony/web-profiler-bundle": "^4.4 || ^5.2", + "symfony/web-server-bundle": "^4.4|^5.2", + "vimeo/psalm": "4.4.1", + "slevomat/coding-standard": "~6.0", + "symfony/dependency-injection": "<4.4.19 || >=5.0.0 <5.2.2", + "friends-of-behat/mink-debug-extension": "^2.0" }, "conflict": { "symfony/symfony": "4.1.8", "symfony/browser-kit": "4.1.8", - "symfony/dependency-injection": "4.1.8", "symfony/dom-crawler": "4.1.8", "symfony/routing": "4.1.8", "symfony/doctrine-bridge": "4.4.16" diff --git a/spec/Controller/Action/AddProductToWishlistActionSpec.php b/spec/Controller/Action/AddProductToWishlistActionSpec.php index 9aeda8b7..c0ce5651 100644 --- a/spec/Controller/Action/AddProductToWishlistActionSpec.php +++ b/spec/Controller/Action/AddProductToWishlistActionSpec.php @@ -9,7 +9,7 @@ use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; use BitBag\SyliusWishlistPlugin\Entity\WishlistProductInterface; use BitBag\SyliusWishlistPlugin\Factory\WishlistProductFactoryInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use PhpSpec\ObjectBehavior; use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Repository\ProductRepositoryInterface; @@ -19,9 +19,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\User\User; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; final class AddProductToWishlistActionSpec extends ObjectBehavior { diff --git a/spec/Controller/Action/AddProductVariantToWishlistActionSpec.php b/spec/Controller/Action/AddProductVariantToWishlistActionSpec.php index 876d087a..adcc999a 100644 --- a/spec/Controller/Action/AddProductVariantToWishlistActionSpec.php +++ b/spec/Controller/Action/AddProductVariantToWishlistActionSpec.php @@ -9,7 +9,7 @@ use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; use BitBag\SyliusWishlistPlugin\Entity\WishlistProductInterface; use BitBag\SyliusWishlistPlugin\Factory\WishlistProductFactoryInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use PhpSpec\ObjectBehavior; use Sylius\Component\Core\Model\ProductVariantInterface; use Sylius\Component\Core\Repository\ProductVariantRepositoryInterface; @@ -19,7 +19,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; final class AddProductVariantToWishlistActionSpec extends ObjectBehavior { diff --git a/spec/Controller/Action/ListWishlistProductsActionSpec.php b/spec/Controller/Action/ListWishlistProductsActionSpec.php index 5494f094..f01956b1 100644 --- a/spec/Controller/Action/ListWishlistProductsActionSpec.php +++ b/spec/Controller/Action/ListWishlistProductsActionSpec.php @@ -16,7 +16,6 @@ use Sylius\Component\Core\Model\OrderItemInterface; use Sylius\Component\Order\Context\CartContextInterface; use Sylius\Component\Order\Modifier\OrderModifierInterface; -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Component\Form\FormErrorIterator; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; @@ -24,7 +23,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; +use Twig\Environment; final class ListWishlistProductsActionSpec extends ObjectBehavior { @@ -36,7 +36,7 @@ function let( EntityManagerInterface $cartManager, FlashBagInterface $flashBag, TranslatorInterface $translator, - EngineInterface $templatingEngine + Environment $twigEnvironment ): void { $this->beConstructedWith( $wishlistContext, @@ -46,7 +46,7 @@ function let( $cartManager, $flashBag, $translator, - $templatingEngine + $twigEnvironment ); } @@ -66,7 +66,7 @@ function it_lists_wishlist_items( FormInterface $form, FormErrorIterator $formErrorIterator, FormView $formView, - EngineInterface $templatingEngine, + Environment $twigEnvironment, Response $response ): void { $wishlistContext->getWishlist($request)->willReturn($wishlist); @@ -86,15 +86,15 @@ function it_lists_wishlist_items( $form->isSubmitted()->willReturn(false); $form->createView()->willReturn($formView); $form->getErrors()->willReturn($formErrorIterator); - $templatingEngine - ->renderResponse( + $twigEnvironment + ->render( '@BitBagSyliusWishlistPlugin/wishlist.html.twig', [ 'wishlist' => $wishlist, 'form' => $formView, ] ) - ->willReturn($response) + ->willReturn('CONTENT') ; $form->handleRequest($request)->shouldBeCalled(); @@ -117,7 +117,7 @@ function it_adds_wishlist_items_to_the_cart( OrderItemInterface $cartItem, OrderModifierInterface $orderModifier, EntityManagerInterface $cartManager, - EngineInterface $templatingEngine, + Environment $twigEnvironment, Response $response ): void { $wishlistContext->getWishlist($request)->willReturn($wishlist); @@ -141,14 +141,14 @@ function it_adds_wishlist_items_to_the_cart( $form->getErrors()->willReturn($formErrorIterator); $addToCartCommand->getCart()->willReturn($cartItem); $cartItem->getQuantity()->willReturn(1); - $templatingEngine - ->renderResponse( + $twigEnvironment + ->render( '@BitBagSyliusWishlistPlugin/wishlist.html.twig', [ 'wishlist' => $wishlist, 'form' => $formView, ] - )->willReturn($response) + )->willReturn('CONTENT') ; $addToCartCommand->getCart()->willReturn($cart); $addToCartCommand->getCartItem()->willReturn($cartItem); diff --git a/spec/Controller/Action/RemoveProductFromWishlistActionSpec.php b/spec/Controller/Action/RemoveProductFromWishlistActionSpec.php index f45fe2de..3718f0fd 100644 --- a/spec/Controller/Action/RemoveProductFromWishlistActionSpec.php +++ b/spec/Controller/Action/RemoveProductFromWishlistActionSpec.php @@ -18,7 +18,7 @@ use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; final class RemoveProductFromWishlistActionSpec extends ObjectBehavior { diff --git a/spec/Controller/Action/RenderHeaderTemplateActionSpec.php b/spec/Controller/Action/RenderHeaderTemplateActionSpec.php index 89898fe6..7c95345c 100644 --- a/spec/Controller/Action/RenderHeaderTemplateActionSpec.php +++ b/spec/Controller/Action/RenderHeaderTemplateActionSpec.php @@ -8,15 +8,15 @@ use BitBag\SyliusWishlistPlugin\Controller\Action\RenderHeaderTemplateAction; use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; use PhpSpec\ObjectBehavior; -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Twig\Environment; final class RenderHeaderTemplateActionSpec extends ObjectBehavior { - function let(WishlistContextInterface $wishlistContext, EngineInterface $templatingEngine): void + function let(WishlistContextInterface $wishlistContext, Environment $twigEnvironment): void { - $this->beConstructedWith($wishlistContext, $templatingEngine); + $this->beConstructedWith($wishlistContext, $twigEnvironment); } function it_is_initializable(): void @@ -28,14 +28,14 @@ function it_renders_header_template( Request $request, WishlistContextInterface $wishlistContext, WishlistInterface $wishlist, - EngineInterface $templatingEngine, + Environment $twigEnvironment, Response $response ): void { $wishlistContext->getWishlist($request)->willReturn($wishlist); - $templatingEngine->renderResponse('@BitBagSyliusWishlistPlugin/_wishlistHeader.html.twig', [ - 'wishlist' => $wishlist, - ])->willReturn($response); - $this->__invoke($request)->shouldReturn($response); + $twigEnvironment->render('@BitBagSyliusWishlistPlugin/_wishlistHeader.html.twig', [ + 'wishlist' => $wishlist, + ])->willReturn('TEMPLATE'); + $this->__invoke($request)->shouldImplement(Response::class); } } diff --git a/spec/DependencyInjection/ConfigurationSpec.php b/spec/DependencyInjection/ConfigurationSpec.php index 320cc3db..453696b2 100644 --- a/spec/DependencyInjection/ConfigurationSpec.php +++ b/spec/DependencyInjection/ConfigurationSpec.php @@ -17,6 +17,6 @@ function it_is_initializable(): void function it_returns_tree_builder(): void { - $this->getConfigTreeBuilder()->shouldBeAnInstanceOf(TreeBuilder::class ); + $this->getConfigTreeBuilder()->shouldBeAnInstanceOf(TreeBuilder::class); } } diff --git a/spec/Entity/WishlistProductSpec.php b/spec/Entity/WishlistProductSpec.php index 2a01cc90..798b15b4 100644 --- a/spec/Entity/WishlistProductSpec.php +++ b/spec/Entity/WishlistProductSpec.php @@ -22,11 +22,6 @@ function it_implements_wishlist_product_interface(): void $this->shouldHaveType(WishlistProductInterface::class); } - function it_has_null_id_by_default(): void - { - $this->getId()->shouldReturn(null); - } - function it_gets_wishlist(WishlistInterface $wishlist): void { $this->setWishlist($wishlist); diff --git a/spec/Entity/WishlistSpec.php b/spec/Entity/WishlistSpec.php index 69ca30c2..9c4d486c 100644 --- a/spec/Entity/WishlistSpec.php +++ b/spec/Entity/WishlistSpec.php @@ -24,11 +24,6 @@ function it_implements_wishlist_interface(): void $this->shouldHaveType(WishlistInterface::class); } - function it_has_null_id_by_default(): void - { - $this->getId()->shouldReturn(null); - } - function it_has_no_products_by_default(): void { $this->getProducts()->toArray()->shouldReturn([]); diff --git a/spec/EventListener/ClearCookieWishlistItemsListenerSpec.php b/spec/EventListener/ClearCookieWishlistItemsListenerSpec.php index 31720312..9b52d964 100644 --- a/spec/EventListener/ClearCookieWishlistItemsListenerSpec.php +++ b/spec/EventListener/ClearCookieWishlistItemsListenerSpec.php @@ -6,10 +6,12 @@ use BitBag\SyliusWishlistPlugin\EventListener\ClearCookieWishlistItemsListener; use PhpSpec\ObjectBehavior; -use Sylius\Component\Core\Model\AdminUserInterface; -use Sylius\Component\Core\Model\ShopUserInterface; +use Sylius\Component\Core\Model\AdminUser; +use Sylius\Component\Core\Model\ShopUser; use Sylius\Component\Resource\Storage\StorageInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; +use Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken; use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; final class ClearCookieWishlistItemsListenerSpec extends ObjectBehavior @@ -25,30 +27,20 @@ function it_is_initializable(): void } function it_does_nothing_if_not_shop_user( - InteractiveLoginEvent $interactiveLoginEvent, - TokenInterface $token, - AdminUserInterface $adminUser, StorageInterface $cookieStorage ): void { - $interactiveLoginEvent->getAuthenticationToken()->willReturn($token); - $token->getUser()->willReturn($adminUser); - + $token = new AnonymousToken('TOKEN', new AdminUser()); + $interactiveLoginEvent = new InteractiveLoginEvent(new Request(), $token); $cookieStorage->set('bitbag_sylius_wishlist', null)->shouldNotBeCalled(); - $this->onInteractiveLogin($interactiveLoginEvent); } function it_adds_cookie_items_to_user_items_if_both_exist( - InteractiveLoginEvent $interactiveLoginEvent, - TokenInterface $token, - ShopUserInterface $shopUser, StorageInterface $cookieStorage ): void { - $interactiveLoginEvent->getAuthenticationToken()->willReturn($token); - $token->getUser()->willReturn($shopUser); - + $token = new PostAuthenticationToken( new ShopUser(), 'test', []); + $interactiveLoginEvent = new InteractiveLoginEvent(new Request(), $token); $cookieStorage->set('bitbag_sylius_wishlist', null)->shouldBeCalled(); - $this->onInteractiveLogin($interactiveLoginEvent); } } diff --git a/spec/EventListener/MergeUserWishlistItemsListenerSpec.php b/spec/EventListener/MergeUserWishlistItemsListenerSpec.php index 3fe6f9de..881f92ff 100644 --- a/spec/EventListener/MergeUserWishlistItemsListenerSpec.php +++ b/spec/EventListener/MergeUserWishlistItemsListenerSpec.php @@ -12,11 +12,12 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\EntityManagerInterface; use PhpSpec\ObjectBehavior; -use Sylius\Component\Core\Model\AdminUserInterface; -use Sylius\Component\Core\Model\ShopUserInterface; +use Sylius\Component\Core\Model\AdminUser; +use Sylius\Component\Core\Model\ShopUser; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; +use Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken; use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; final class MergeUserWishlistItemsListenerSpec extends ObjectBehavior @@ -40,13 +41,10 @@ function it_is_initializable(): void } function it_does_nothing_if_not_shop_user( - InteractiveLoginEvent $interactiveLoginEvent, - TokenInterface $token, - AdminUserInterface $adminUser, EntityManagerInterface $wishlistManager ): void { - $interactiveLoginEvent->getAuthenticationToken()->willReturn($token); - $token->getUser()->willReturn($adminUser); + $token = new AnonymousToken('TOKEN', new AdminUser()); + $interactiveLoginEvent = new InteractiveLoginEvent(new Request(), $token); $wishlistManager->flush()->shouldNotBeCalled(); @@ -54,22 +52,19 @@ function it_does_nothing_if_not_shop_user( } function it_adds_cookie_items_to_user_items_if_both_exist( - InteractiveLoginEvent $interactiveLoginEvent, - TokenInterface $token, - ShopUserInterface $shopUser, - Request $request, - ParameterBag $parameterBag, WishlistRepositoryInterface $wishlistRepository, WishlistInterface $cookieWishlist, WishlistInterface $userWishlist, WishlistProductInterface $wishlistProduct, EntityManagerInterface $wishlistManager ): void { - $interactiveLoginEvent->getAuthenticationToken()->willReturn($token); - $token->getUser()->willReturn($shopUser); - $interactiveLoginEvent->getRequest()->willReturn($request); - $request->cookies = $parameterBag; - $parameterBag->get('bitbag_sylius_wishlist', '')->willReturn('Fq8N4W6mk12i9J2HX0U60POGG5UEzSgGW37OWd6sv2dd8FlBId'); + $shopUser = new ShopUser(); + $token = new PostAuthenticationToken( $shopUser, 'test', []); + $request = new Request(); + $request->cookies = new ParameterBag([ + 'bitbag_sylius_wishlist' => 'Fq8N4W6mk12i9J2HX0U60POGG5UEzSgGW37OWd6sv2dd8FlBId' + ]); + $interactiveLoginEvent = new InteractiveLoginEvent($request, $token); $wishlistRepository->findByToken('Fq8N4W6mk12i9J2HX0U60POGG5UEzSgGW37OWd6sv2dd8FlBId')->willReturn($cookieWishlist); $wishlistRepository->findByShopUser($shopUser)->willReturn($userWishlist); $cookieWishlist->getWishlistProducts()->willReturn(new ArrayCollection([$wishlistProduct->getWrappedObject()])); @@ -81,20 +76,18 @@ function it_adds_cookie_items_to_user_items_if_both_exist( } function it_associates_anon_wishlsit_with_a_user_if_user_does_not_have_one( - InteractiveLoginEvent $interactiveLoginEvent, - TokenInterface $token, - ShopUserInterface $shopUser, - Request $request, - ParameterBag $parameterBag, WishlistRepositoryInterface $wishlistRepository, WishlistInterface $cookieWishlist, EntityManagerInterface $wishlistManager ): void { - $interactiveLoginEvent->getAuthenticationToken()->willReturn($token); - $token->getUser()->willReturn($shopUser); - $interactiveLoginEvent->getRequest()->willReturn($request); - $request->cookies = $parameterBag; - $parameterBag->get('bitbag_sylius_wishlist', '')->willReturn('Fq8N4W6mk12i9J2HX0U60POGG5UEzSgGW37OWd6sv2dd8FlBId'); + $shopUser = new ShopUser(); + $token = new PostAuthenticationToken( $shopUser, 'test', []); + $request = new Request(); + $request->cookies = new ParameterBag([ + 'bitbag_sylius_wishlist' => 'Fq8N4W6mk12i9J2HX0U60POGG5UEzSgGW37OWd6sv2dd8FlBId' + ]); + $interactiveLoginEvent = new InteractiveLoginEvent($request, $token); + $wishlistRepository->findByToken('Fq8N4W6mk12i9J2HX0U60POGG5UEzSgGW37OWd6sv2dd8FlBId')->willReturn($cookieWishlist); $wishlistRepository->findByShopUser($shopUser)->willReturn(null); diff --git a/src/Context/WishlistContext.php b/src/Context/WishlistContext.php index c10b2d0d..e35ee8a0 100644 --- a/src/Context/WishlistContext.php +++ b/src/Context/WishlistContext.php @@ -21,17 +21,13 @@ final class WishlistContext implements WishlistContextInterface { - /** @var TokenStorageInterface */ - private $tokenStorage; + private TokenStorageInterface $tokenStorage; - /** @var WishlistRepositoryInterface */ - private $wishlistRepository; + private WishlistRepositoryInterface $wishlistRepository; - /** @var WishlistFactoryInterface */ - private $wishlistFactory; + private WishlistFactoryInterface $wishlistFactory; - /** @var string */ - private $wishlistCookieToken; + private string $wishlistCookieToken; public function __construct( TokenStorageInterface $tokenStorage, diff --git a/src/Controller/Action/AddProductToWishlistAction.php b/src/Controller/Action/AddProductToWishlistAction.php index 50902e81..a3c62848 100644 --- a/src/Controller/Action/AddProductToWishlistAction.php +++ b/src/Controller/Action/AddProductToWishlistAction.php @@ -16,7 +16,7 @@ use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; use BitBag\SyliusWishlistPlugin\Entity\WishlistProductInterface; use BitBag\SyliusWishlistPlugin\Factory\WishlistProductFactoryInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Repository\ProductRepositoryInterface; use Symfony\Component\HttpFoundation\Cookie; @@ -27,36 +27,27 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; final class AddProductToWishlistAction { - /** @var TokenStorageInterface */ - private $tokenStorage; + private TokenStorageInterface $tokenStorage; - /** @var ProductRepositoryInterface */ - private $productRepository; + private ProductRepositoryInterface $productRepository; - /** @var WishlistContextInterface */ - private $wishlistContext; + private WishlistContextInterface $wishlistContext; - /** @var WishlistProductFactoryInterface */ - private $wishlistProductFactory; + private WishlistProductFactoryInterface $wishlistProductFactory; - /** @var ObjectManager */ - private $wishlistManager; + private ObjectManager $wishlistManager; - /** @var FlashBagInterface */ - private $flashBag; + private FlashBagInterface $flashBag; - /** @var TranslatorInterface */ - private $translator; + private TranslatorInterface $translator; - /** @var UrlGeneratorInterface */ - private $urlGenerator; + private UrlGeneratorInterface $urlGenerator; - /** @var string */ - private $wishlistCookieToken; + private string $wishlistCookieToken; public function __construct( TokenStorageInterface $tokenStorage, diff --git a/src/Controller/Action/AddProductVariantToWishlistAction.php b/src/Controller/Action/AddProductVariantToWishlistAction.php index 9a43c3a4..3c311f28 100644 --- a/src/Controller/Action/AddProductVariantToWishlistAction.php +++ b/src/Controller/Action/AddProductVariantToWishlistAction.php @@ -16,7 +16,7 @@ use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; use BitBag\SyliusWishlistPlugin\Entity\WishlistProductInterface; use BitBag\SyliusWishlistPlugin\Factory\WishlistProductFactoryInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use Sylius\Component\Core\Model\ProductVariantInterface; use Sylius\Component\Core\Repository\ProductVariantRepositoryInterface; use Symfony\Component\HttpFoundation\Cookie; @@ -27,36 +27,27 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; final class AddProductVariantToWishlistAction { - /** @var TokenStorageInterface */ - private $tokenStorage; + private TokenStorageInterface $tokenStorage; - /** @var ProductVariantRepositoryInterface */ - private $productVariantRepository; + private ProductVariantRepositoryInterface $productVariantRepository; - /** @var WishlistContextInterface */ - private $wishlistContext; + private WishlistContextInterface $wishlistContext; - /** @var WishlistProductFactoryInterface */ - private $wishlistProductFactory; + private WishlistProductFactoryInterface $wishlistProductFactory; - /** @var ObjectManager */ - private $wishlistManager; + private ObjectManager $wishlistManager; - /** @var FlashBagInterface */ - private $flashBag; + private FlashBagInterface $flashBag; - /** @var TranslatorInterface */ - private $translator; + private TranslatorInterface $translator; - /** @var UrlGeneratorInterface */ - private $urlGenerator; + private UrlGeneratorInterface $urlGenerator; - /** @var string */ - private $wishlistCookieToken; + private string $wishlistCookieToken; public function __construct( TokenStorageInterface $tokenStorage, diff --git a/src/Controller/Action/ListWishlistProductsAction.php b/src/Controller/Action/ListWishlistProductsAction.php index 8446bae8..2255ede1 100644 --- a/src/Controller/Action/ListWishlistProductsAction.php +++ b/src/Controller/Action/ListWishlistProductsAction.php @@ -18,39 +18,31 @@ use Sylius\Bundle\OrderBundle\Controller\AddToCartCommandInterface; use Sylius\Component\Order\Context\CartContextInterface; use Sylius\Component\Order\Modifier\OrderModifierInterface; -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; +use Twig\Environment; final class ListWishlistProductsAction { - /** @var WishlistContextInterface */ - private $wishlistContext; + private WishlistContextInterface $wishlistContext; - /** @var CartContextInterface */ - private $cartContext; + private CartContextInterface $cartContext; - /** @var FormFactoryInterface */ - private $formFactory; + private FormFactoryInterface $formFactory; - /** @var OrderModifierInterface */ - private $orderModifier; + private OrderModifierInterface $orderModifier; - /** @var EntityManagerInterface */ - private $cartManager; + private EntityManagerInterface $cartManager; - /** @var FlashBagInterface */ - private $flashBag; + private FlashBagInterface $flashBag; - /** @var TranslatorInterface */ - private $translator; + private TranslatorInterface $translator; - /** @var EngineInterface */ - private $templatingEngine; + private Environment $twigEnvironment; public function __construct( WishlistContextInterface $wishlistContext, @@ -60,14 +52,14 @@ public function __construct( EntityManagerInterface $cartManager, FlashBagInterface $flashBag, TranslatorInterface $translator, - EngineInterface $templatingEngine + Environment $twigEnvironment ) { $this->wishlistContext = $wishlistContext; $this->cartContext = $cartContext; $this->formFactory = $formFactory; $this->orderModifier = $orderModifier; $this->flashBag = $flashBag; - $this->templatingEngine = $templatingEngine; + $this->twigEnvironment = $twigEnvironment; $this->cartManager = $cartManager; $this->translator = $translator; } @@ -89,20 +81,24 @@ public function __invoke(Request $request): Response $this->flashBag->add('success', $this->translator->trans('bitbag_sylius_wishlist_plugin.ui.added_to_cart')); - return $this->templatingEngine->renderResponse('@BitBagSyliusWishlistPlugin/wishlist.html.twig', [ - 'wishlist' => $wishlist, - 'form' => $form->createView(), - ]); + return new Response( + $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/wishlist.html.twig', [ + 'wishlist' => $wishlist, + 'form' => $form->createView(), + ]) + ); } foreach ($form->getErrors() as $error) { $this->flashBag->add('error', $error->getMessage()); } - return $this->templatingEngine->renderResponse('@BitBagSyliusWishlistPlugin/wishlist.html.twig', [ - 'wishlist' => $wishlist, - 'form' => $form->createView(), - ]); + return new Response( + $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/wishlist.html.twig', [ + 'wishlist' => $wishlist, + 'form' => $form->createView(), + ]) + ); } private function handleCartItems(FormInterface $form): void diff --git a/src/Controller/Action/RemoveProductFromWishlistAction.php b/src/Controller/Action/RemoveProductFromWishlistAction.php index 1f51ada5..ca28c738 100644 --- a/src/Controller/Action/RemoveProductFromWishlistAction.php +++ b/src/Controller/Action/RemoveProductFromWishlistAction.php @@ -22,27 +22,21 @@ use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; final class RemoveProductFromWishlistAction { - /** @var WishlistContextInterface */ - private $wishlistContext; + private WishlistContextInterface $wishlistContext; - /** @var ProductRepositoryInterface */ - private $productRepository; + private ProductRepositoryInterface $productRepository; - /** @var EntityManagerInterface */ - private $wishlistProductManager; + private EntityManagerInterface $wishlistProductManager; - /** @var FlashBagInterface */ - private $flashBag; + private FlashBagInterface $flashBag; - /** @var TranslatorInterface */ - private $translator; + private TranslatorInterface $translator; - /** @var UrlGeneratorInterface */ - private $urlGenerator; + private UrlGeneratorInterface $urlGenerator; public function __construct( WishlistContextInterface $wishlistContext, diff --git a/src/Controller/Action/RemoveProductVariantFromWishlistAction.php b/src/Controller/Action/RemoveProductVariantFromWishlistAction.php index dfbdb4d9..ffa1a47f 100644 --- a/src/Controller/Action/RemoveProductVariantFromWishlistAction.php +++ b/src/Controller/Action/RemoveProductVariantFromWishlistAction.php @@ -22,27 +22,21 @@ use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; final class RemoveProductVariantFromWishlistAction { - /** @var WishlistContextInterface */ - private $wishlistContext; + private WishlistContextInterface $wishlistContext; - /** @var ProductVariantRepositoryInterface */ - private $productVariantRepository; + private ProductVariantRepositoryInterface $productVariantRepository; - /** @var EntityManagerInterface */ - private $wishlistProductManager; + private EntityManagerInterface $wishlistProductManager; - /** @var FlashBagInterface */ - private $flashBag; + private FlashBagInterface $flashBag; - /** @var TranslatorInterface */ - private $translator; + private TranslatorInterface $translator; - /** @var UrlGeneratorInterface */ - private $urlGenerator; + private UrlGeneratorInterface $urlGenerator; public function __construct( WishlistContextInterface $wishlistContext, diff --git a/src/Controller/Action/RenderHeaderTemplateAction.php b/src/Controller/Action/RenderHeaderTemplateAction.php index a8a0bc7c..dffe152d 100644 --- a/src/Controller/Action/RenderHeaderTemplateAction.php +++ b/src/Controller/Action/RenderHeaderTemplateAction.php @@ -13,30 +13,30 @@ namespace BitBag\SyliusWishlistPlugin\Controller\Action; use BitBag\SyliusWishlistPlugin\Context\WishlistContextInterface; -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Twig\Environment; final class RenderHeaderTemplateAction { - /** @var WishlistContextInterface */ - private $wishlistContext; + private WishlistContextInterface $wishlistContext; - /** @var EngineInterface */ - private $templatingEngine; + private Environment $twigEnvironment; - public function __construct(WishlistContextInterface $wishlistContext, EngineInterface $templatingEngine) + public function __construct(WishlistContextInterface $wishlistContext, Environment $twigEnvironment) { $this->wishlistContext = $wishlistContext; - $this->templatingEngine = $templatingEngine; + $this->twigEnvironment = $twigEnvironment; } public function __invoke(Request $request): Response { $wishlist = $this->wishlistContext->getWishlist($request); - return $this->templatingEngine->renderResponse('@BitBagSyliusWishlistPlugin/_wishlistHeader.html.twig', [ - 'wishlist' => $wishlist, - ]); + return new Response( + $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/_wishlistHeader.html.twig', [ + 'wishlist' => $wishlist, + ]) + ); } } diff --git a/src/Entity/Wishlist.php b/src/Entity/Wishlist.php index ab0c8327..46505ab0 100644 --- a/src/Entity/Wishlist.php +++ b/src/Entity/Wishlist.php @@ -17,26 +17,24 @@ use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Model\ProductVariantInterface; use Sylius\Component\Core\Model\ShopUserInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; class Wishlist implements WishlistInterface { - /** @var int */ - protected $id; + protected ?int $id; /** @var Collection|WishlistProductInterface[] */ protected $wishlistProducts; - /** @var ShopUserInterface|null */ - protected $shopUser; + protected ?ShopUserInterface $shopUser; - /** @var TokenInterface|null */ + /** @var WishlistTokenInterface|null */ protected $token; public function __construct() { $this->wishlistProducts = new ArrayCollection(); $this->token = new WishlistToken(); + $this->id = null; } public function getId(): ?int diff --git a/src/Entity/WishlistProduct.php b/src/Entity/WishlistProduct.php index 6b7e3b17..5c93e4e2 100644 --- a/src/Entity/WishlistProduct.php +++ b/src/Entity/WishlistProduct.php @@ -17,20 +17,20 @@ class WishlistProduct implements WishlistProductInterface { - /** @var int */ - protected $id; + protected ?int $id; - /** @var WishlistInterface */ - protected $wishlist; + protected WishlistInterface $wishlist; - /** @var ProductInterface */ - protected $product; + protected ?ProductInterface $product; - /** @var ProductVariantInterface|null */ - protected $variant; + protected ?ProductVariantInterface $variant; - /** @var int */ - protected $quantity = 0; + protected int $quantity = 0; + + public function __construct() + { + $this->id = null; + } public function getId(): ?int { diff --git a/src/Entity/WishlistToken.php b/src/Entity/WishlistToken.php index de99acf1..45dbb25a 100644 --- a/src/Entity/WishlistToken.php +++ b/src/Entity/WishlistToken.php @@ -8,7 +8,7 @@ class WishlistToken implements WishlistTokenInterface { - protected $value; + protected string $value; public function __construct(?string $value = null) { @@ -29,7 +29,7 @@ public function setValue(string $value): void $this->value = $value; } - public function __toString() + public function __toString(): string { return $this->getValue(); } diff --git a/src/EventListener/ClearCookieWishlistItemsListener.php b/src/EventListener/ClearCookieWishlistItemsListener.php index 1f7d65d6..194db255 100644 --- a/src/EventListener/ClearCookieWishlistItemsListener.php +++ b/src/EventListener/ClearCookieWishlistItemsListener.php @@ -18,11 +18,9 @@ final class ClearCookieWishlistItemsListener { - /** @var StorageInterface */ - private $cookieStorage; + private StorageInterface $cookieStorage; - /** @var string */ - private $wishlistCookieToken; + private string $wishlistCookieToken; public function __construct(StorageInterface $cookieStorage, string $wishlistCookieToken) { diff --git a/src/EventListener/MergeUserWishlistItemsListener.php b/src/EventListener/MergeUserWishlistItemsListener.php index 352a6549..46f7b44a 100644 --- a/src/EventListener/MergeUserWishlistItemsListener.php +++ b/src/EventListener/MergeUserWishlistItemsListener.php @@ -15,7 +15,7 @@ use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; use BitBag\SyliusWishlistPlugin\Factory\WishlistFactoryInterface; use BitBag\SyliusWishlistPlugin\Repository\WishlistRepositoryInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use Sylius\Component\Core\Model\ShopUserInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; diff --git a/src/Factory/WishlistFactory.php b/src/Factory/WishlistFactory.php index 7189264b..9690b637 100644 --- a/src/Factory/WishlistFactory.php +++ b/src/Factory/WishlistFactory.php @@ -18,8 +18,7 @@ final class WishlistFactory implements WishlistFactoryInterface { - /** @var FactoryInterface */ - private $wishlistFactory; + private FactoryInterface $wishlistFactory; public function __construct(FactoryInterface $wishlistFactory) { diff --git a/src/Factory/WishlistProductFactory.php b/src/Factory/WishlistProductFactory.php index 9050e96b..ca44c4a7 100644 --- a/src/Factory/WishlistProductFactory.php +++ b/src/Factory/WishlistProductFactory.php @@ -20,8 +20,7 @@ final class WishlistProductFactory implements WishlistProductFactoryInterface { - /** @var FactoryInterface */ - private $wishlistProductFactory; + private FactoryInterface $wishlistProductFactory; public function __construct(FactoryInterface $wishlistProductFactory) { diff --git a/src/Form/Extension/AddToCartTypeExtension.php b/src/Form/Extension/AddToCartTypeExtension.php index cc5e1960..37b74c82 100644 --- a/src/Form/Extension/AddToCartTypeExtension.php +++ b/src/Form/Extension/AddToCartTypeExtension.php @@ -10,7 +10,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -class AddToCartTypeExtension extends AbstractTypeExtension +final class AddToCartTypeExtension extends AbstractTypeExtension { public function buildForm(FormBuilderInterface $builder, array $options): void { @@ -26,7 +26,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void } } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefault('is_wishlist', false) diff --git a/src/Form/Type/AddProductsToCartType.php b/src/Form/Type/AddProductsToCartType.php index d49738d6..d282df18 100644 --- a/src/Form/Type/AddProductsToCartType.php +++ b/src/Form/Type/AddProductsToCartType.php @@ -18,17 +18,15 @@ final class AddProductsToCartType extends AbstractType { - /** @var AddToCartCommandFactoryInterface */ - private $addToCartCommandFactory; + private AddToCartCommandFactoryInterface $addToCartCommandFactory; /** @var FactoryInterface */ private $cartItemFactory; - /** @var OrderItemQuantityModifierInterface */ - private $orderItemQuantityModifier; + private OrderItemQuantityModifierInterface $orderItemQuantityModifier; /** @var string[] */ - private $validationGroups; + private array $validationGroups; public function __construct( AddToCartCommandFactoryInterface $addToCartCommandFactory, diff --git a/src/Resources/config/config.yml b/src/Resources/config/config.yml index 79b5aba7..75160f19 100644 --- a/src/Resources/config/config.yml +++ b/src/Resources/config/config.yml @@ -1,3 +1,4 @@ imports: - { resource: "@BitBagSyliusWishlistPlugin/Resources/config/services.yml" } - { resource: "@BitBagSyliusWishlistPlugin/Resources/config/resources.yml" } + - { resource: "@BitBagSyliusWishlistPlugin/Resources/config/sylius_ui.yml" } diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index ee71d86a..aeda2eb1 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -64,7 +64,7 @@ services: - "@sylius.manager.order" - "@session.flash_bag" - "@translator" - - "@templating.engine.twig" + - "@twig" tags: - { name: controller.service_arguments } @@ -72,7 +72,7 @@ services: class: BitBag\SyliusWishlistPlugin\Controller\Action\RenderHeaderTemplateAction arguments: - "@bitbag_sylius_wishlist_plugin.context.wishlist" - - "@templating.engine.twig" + - "@twig" tags: - { name: controller.service_arguments } @@ -132,10 +132,3 @@ services: class: BitBag\SyliusWishlistPlugin\Form\Extension\AddToCartTypeExtension tags: - { name: form.type_extension, extended_type: Sylius\Bundle\CoreBundle\Form\Type\Order\AddToCartType } - - bitbag.block_event_listener.shop.layout.javascripts: - class: Sylius\Bundle\UiBundle\Block\BlockEventListener - arguments: - - "@@BitBagSyliusWishlistPlugin/Resources/views/_javascripts.html.twig" - tags: - - { name: kernel.event_listener, event: sonata.block.event.sylius.shop.layout.javascripts, method: onBlockEvent } diff --git a/src/Resources/config/sylius_ui.yml b/src/Resources/config/sylius_ui.yml new file mode 100644 index 00000000..4e50008f --- /dev/null +++ b/src/Resources/config/sylius_ui.yml @@ -0,0 +1,7 @@ +sylius_ui: + events: + sylius.shop.layout.javascripts: + blocks: + bitbag_wishlist_scripts: + template: "@BitBagSyliusWishlistPlugin/_javascripts.html.twig" + priority: 0 diff --git a/src/Resources/views/_javascripts.html.twig b/src/Resources/views/_javascripts.html.twig index ddbc6aed..dd7faa15 100644 --- a/src/Resources/views/_javascripts.html.twig +++ b/src/Resources/views/_javascripts.html.twig @@ -1 +1 @@ -{% include 'SyliusUiBundle::_javascripts.html.twig' with {'path': 'bundles/bitbagsyliuswishlistplugin/js/addToWishlist.js'} %} \ No newline at end of file +{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/bitbagsyliuswishlistplugin/js/addToWishlist.js'} %} diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 1cbd59bf..f7758cde 100755 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -85,7 +85,7 @@ protected function getContainerLoader(ContainerInterface $container): LoaderInte /** @var ContainerBuilder $container */ Assert::isInstanceOf($container, ContainerBuilder::class); - $locator = new FileLocator($this, $this->getRootDir() . '/Resources'); + $locator = new FileLocator($this); $resolver = new LoaderResolver(array( new XmlFileLoader($container, $locator), new YamlFileLoader($container, $locator), diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 418230ea..27d161cf 100755 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -7,7 +7,6 @@ Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], - Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true], Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true], @@ -40,7 +39,7 @@ Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], - WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true], + BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true], Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true], @@ -59,6 +58,7 @@ Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], BitBag\SyliusWishlistPlugin\BitBagSyliusWishlistPlugin::class => ['all' => true], + SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/packages/dev/jms_serializer.yaml b/tests/Application/config/packages/dev/jms_serializer.yaml index 353e4602..2f32a9b1 100755 --- a/tests/Application/config/packages/dev/jms_serializer.yaml +++ b/tests/Application/config/packages/dev/jms_serializer.yaml @@ -1,6 +1,11 @@ jms_serializer: visitors: - json: + json_serialization: + options: + - JSON_PRETTY_PRINT + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION + json_deserialization: options: - JSON_PRETTY_PRINT - JSON_UNESCAPED_SLASHES diff --git a/tests/Application/config/packages/framework.yaml b/tests/Application/config/packages/framework.yaml index e74ed811..9b445011 100755 --- a/tests/Application/config/packages/framework.yaml +++ b/tests/Application/config/packages/framework.yaml @@ -2,6 +2,5 @@ framework: secret: '%env(APP_SECRET)%' form: true csrf_protection: true - templating: { engines: ["twig"] } session: handler_id: ~ diff --git a/tests/Application/config/packages/jms_serializer.yaml b/tests/Application/config/packages/jms_serializer.yaml deleted file mode 100755 index 64dd8d10..00000000 --- a/tests/Application/config/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/packages/prod/jms_serializer.yaml b/tests/Application/config/packages/prod/jms_serializer.yaml index bc97faf1..c2881820 100755 --- a/tests/Application/config/packages/prod/jms_serializer.yaml +++ b/tests/Application/config/packages/prod/jms_serializer.yaml @@ -1,6 +1,10 @@ jms_serializer: visitors: - json: + json_serialization: + options: + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION + json_deserialization: options: - JSON_UNESCAPED_SLASHES - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/routes/dev/twig.yaml b/tests/Application/config/routes/dev/twig.yaml index f4ee8396..bcbbf13d 100755 --- a/tests/Application/config/routes/dev/twig.yaml +++ b/tests/Application/config/routes/dev/twig.yaml @@ -1,3 +1,3 @@ _errors: - resource: '@TwigBundle/Resources/config/routing/errors.xml' + resource: '@FrameworkBundle/Resources/config/routing/errors.xml' prefix: /_error diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index 885a3a18..8e067685 100755 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Symfony\Component\Debug\Debug; +use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\HttpFoundation\Request; use Tests\BitBag\SyliusWishlistPlugin\Application\Kernel; diff --git a/tests/Behat/Context/Setup/WishlistContext.php b/tests/Behat/Context/Setup/WishlistContext.php index 9909e87d..8824817f 100644 --- a/tests/Behat/Context/Setup/WishlistContext.php +++ b/tests/Behat/Context/Setup/WishlistContext.php @@ -27,32 +27,23 @@ final class WishlistContext implements Context { - /** @var ProductRepositoryInterface */ - private $productRepository; + private ProductRepositoryInterface $productRepository; - /** @var WishlistContextInterface */ - private $wishlistContext; + private WishlistContextInterface $wishlistContext; - /** @var WishlistProductFactoryInterface */ - private $wishlistProductFactory; + private WishlistProductFactoryInterface $wishlistProductFactory; - /** @var EntityManagerInterface */ - private $wishlistManager; + private EntityManagerInterface $wishlistManager; - /** @var FactoryInterface */ - private $taxonFactory; + private FactoryInterface $taxonFactory; - /** @var FactoryInterface */ - private $productTaxonFactory; + private FactoryInterface $productTaxonFactory; - /** @var EntityManagerInterface */ - private $productTaxonManager; + private EntityManagerInterface $productTaxonManager; - /** @var CookieSetterInterface */ - private $cookieSetter; + private CookieSetterInterface $cookieSetter; - /** @var string */ - private $wishlistCookieToken; + private string $wishlistCookieToken; public function __construct( ProductRepositoryInterface $productRepository, diff --git a/tests/Behat/Context/Ui/WishlistContext.php b/tests/Behat/Context/Ui/WishlistContext.php index ac3e6567..9bc0c859 100644 --- a/tests/Behat/Context/Ui/WishlistContext.php +++ b/tests/Behat/Context/Ui/WishlistContext.php @@ -26,26 +26,19 @@ final class WishlistContext implements Context { - /** @var ProductRepositoryInterface */ - private $productRepository; + private ProductRepositoryInterface $productRepository; - /** @var ProductIndexPageInterface */ - private $productIndexPage; + private ProductIndexPageInterface $productIndexPage; - /** @var ProductShowPageInterface */ - private $productShowPage; + private ProductShowPageInterface $productShowPage; - /** @var WishlistPageInterface */ - private $wishlistPage; + private WishlistPageInterface $wishlistPage; - /** @var NotificationCheckerInterface */ - private $notificationChecker; + private NotificationCheckerInterface $notificationChecker; - /** @var LoginerInterface */ - private $loginer; + private LoginerInterface $loginer; - /** @var WishlistCreatorInterface */ - private $wishlistCreator; + private WishlistCreatorInterface $wishlistCreator; public function __construct( ProductRepositoryInterface $productRepository, diff --git a/tests/Behat/Service/Loginer.php b/tests/Behat/Service/Loginer.php index a4804fea..10613ac9 100644 --- a/tests/Behat/Service/Loginer.php +++ b/tests/Behat/Service/Loginer.php @@ -23,25 +23,20 @@ final class Loginer implements LoginerInterface { private const EXAMPLE_USER_LOGIN = 'shop@exaple.com'; + private const EXAMPLE_USER_PASSWORD = 'bitbag'; - /** @var FactoryInterface */ - private $customerFactory; + private FactoryInterface $customerFactory; - /** @var FactoryInterface */ - private $shopUserFactory; + private FactoryInterface $shopUserFactory; - /** @var RepositoryInterface */ - private $shopUserRepository; + private RepositoryInterface $shopUserRepository; - /** @var TokenStorageInterface */ - private $tokenStorage; + private TokenStorageInterface $tokenStorage; - /** @var LoginPageInterface */ - private $loginPage; + private LoginPageInterface $loginPage; - /** @var HomePageInterface */ - private $homePage; + private HomePageInterface $homePage; public function __construct( FactoryInterface $customerFactory, diff --git a/tests/Behat/Service/WishlistCreator.php b/tests/Behat/Service/WishlistCreator.php index 1344320a..2564b902 100644 --- a/tests/Behat/Service/WishlistCreator.php +++ b/tests/Behat/Service/WishlistCreator.php @@ -20,14 +20,11 @@ final class WishlistCreator implements WishlistCreatorInterface { - /** @var WishlistFactoryInterface */ - private $wishlistFactory; + private WishlistFactoryInterface $wishlistFactory; - /** @var WishlistProductFactoryInterface */ - private $wishlistProductFactory; + private WishlistProductFactoryInterface $wishlistProductFactory; - /** @var RepositoryInterface */ - private $wishlistRepository; + private RepositoryInterface $wishlistRepository; public function __construct( WishlistFactoryInterface $wishlistFactory,