Skip to content

Commit

Permalink
Merge pull request #45 from BitBagCommerce/update-sylius-1-9
Browse files Browse the repository at this point in the history
Update to support Sylius 1.9 and Symfony 5.2
  • Loading branch information
pptasinski-bitbag authored Mar 8, 2021
2 parents 5516300 + c0330d4 commit 412d496
Show file tree
Hide file tree
Showing 44 changed files with 227 additions and 324 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]/sylius?serverVersion=${{ matrix.mysql }}"
Expand Down
31 changes: 16 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions spec/Controller/Action/AddProductToWishlistActionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down
24 changes: 12 additions & 12 deletions spec/Controller/Action/ListWishlistProductsActionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
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;
use Symfony\Component\Form\FormView;
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
{
Expand All @@ -36,7 +36,7 @@ function let(
EntityManagerInterface $cartManager,
FlashBagInterface $flashBag,
TranslatorInterface $translator,
EngineInterface $templatingEngine
Environment $twigEnvironment
): void {
$this->beConstructedWith(
$wishlistContext,
Expand All @@ -46,7 +46,7 @@ function let(
$cartManager,
$flashBag,
$translator,
$templatingEngine
$twigEnvironment
);
}

Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
16 changes: 8 additions & 8 deletions spec/Controller/Action/RenderHeaderTemplateActionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion spec/DependencyInjection/ConfigurationSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
5 changes: 0 additions & 5 deletions spec/Entity/WishlistProductSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions spec/Entity/WishlistSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
Expand Down
26 changes: 9 additions & 17 deletions spec/EventListener/ClearCookieWishlistItemsListenerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
Loading

0 comments on commit 412d496

Please sign in to comment.