-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sylius 1.13 support and wishlist code update (#212)
* OP-169: Adjust code for PHP8.1 style * OP-169: Add first batch of PHPSpec tests * OP-169: Adjust PHP version in composer.json to 8.1 * OP-169: Misc source code improvements * OP-169: Add additional command handler specs * OP-169: Finish adding command handler specs, adjust code style of existing specs * Resolve conflicts * Fix php spec tests * Remove php 8.0 from build * Remove doubled service import * Fix incorrect message bus declaration * Add package json file for Sylius 1.13 * Fix interface * Fix package json name for Sylius 1.13 * Try to fix tests for Sylius 1.13 * Fix bundles file for Sylius 1.13, add wait after ajax call in behat * Fix semantic versioning in build for Sylius 1.13 * Add lchrusciel api test case package * Add wishlist repository test * Fix indent and add php unit tests for CI * Add functional wishlist api tests * Downgrade nelmio/alice package for symfony 5.4 support * Add phpunit bridge package * Drop support for Sylius 1.11, add support for Sylius 1.13 * Add php unit configuration file to git * Remove configuration for Sylius 1.11 * Revert php unit bridge package * Add prefer source for sylius package * Split API responses between Sylius version * Update security for Sylius 1.12 and 1.13, remove generic file * Change deprecated twig function * Revert "Change deprecated twig function" This reverts commit 7cd0b32. * Remove redundant php spec tests, add missing scenarios * CR fixes + OS headers --------- Co-authored-by: Marek Rzytki <[email protected]>
- Loading branch information
1 parent
8b77081
commit f02f2c1
Showing
142 changed files
with
3,881 additions
and
1,045 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
!/etc/build/.gitignore | ||
|
||
/behat.yml | ||
/phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,11 +32,15 @@ Feature: Assigning a wishlist to a user | |
@ui @javascript | ||
Scenario: Assigning a wishlist to a user and logout | ||
When I go to "/" | ||
And I go to "/wishlists" | ||
And I should have 0 wishlists | ||
And I log in as "[email protected]" | ||
And I go to "/wishlists" | ||
And I should have 2 wishlists | ||
And I press "wishlist-edit-button-Wishlist1" | ||
And I fill in "edit_wishlist_name" with "Wishlist-assigned" | ||
And I press "edit_wishlist_save" | ||
And I should wait for one second | ||
And I log out | ||
And I go to "/wishlists" | ||
Then I should have 0 wishlists | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
backupGlobals="false" | ||
colors="true" | ||
bootstrap="tests/Application/config/bootstrap.php" | ||
> | ||
<php> | ||
<ini name="error_reporting" value="-1" /> | ||
|
||
<env name="APP_SECRET" value="''" /> | ||
<env name="APP_ENV" value="test"/> | ||
<env name="APP_DEBUG" value="0"/> | ||
<env name="SHELL_VERBOSITY" value="-1" /> | ||
|
||
<server name="KERNEL_CLASS" value="Tests\BitBag\SyliusWishlistPlugin\Application\Kernel" /> | ||
<server name="KERNEL_CLASS_PATH" value="/tests/Application/Kernel.php" /> | ||
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true"/> | ||
<server name="SHELL_VERBOSITY" value="-1" /> | ||
<server name="ESCAPE_JSON" value="true" /> | ||
</php> | ||
|
||
<testsuites> | ||
<testsuite name="Project Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\SyliusWishlistPlugin\Checker; | ||
|
||
use BitBag\SyliusWishlistPlugin\Checker\WishlistNameChecker; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class WishlistNameCheckerSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(WishlistNameChecker::class); | ||
} | ||
|
||
public function it_returns_true_if_names_are_equal(): void | ||
{ | ||
$existingWishlistName = 'test1'; | ||
$wishlistToCreate = 'test1'; | ||
|
||
$this->check($existingWishlistName, $wishlistToCreate)->shouldReturn(true); | ||
} | ||
|
||
public function it_returns_false_if_names_are_not_equal(): void | ||
{ | ||
$existingWishlistName = 'test1'; | ||
$wishlistToCreate = 'test2'; | ||
|
||
$this->check($existingWishlistName, $wishlistToCreate)->shouldReturn(false); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
spec/CommandHandler/Wishlist/AddProductToSelectedWishlistHandlerSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\SyliusWishlistPlugin\CommandHandler\Wishlist; | ||
|
||
use BitBag\SyliusWishlistPlugin\Command\Wishlist\AddProductToSelectedWishlist; | ||
use BitBag\SyliusWishlistPlugin\Command\Wishlist\AddProductToSelectedWishlistInterface; | ||
use BitBag\SyliusWishlistPlugin\CommandHandler\Wishlist\AddProductToSelectedWishlistHandler; | ||
use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; | ||
use BitBag\SyliusWishlistPlugin\Entity\WishlistProductInterface; | ||
use BitBag\SyliusWishlistPlugin\Factory\WishlistProductFactoryInterface; | ||
use BitBag\SyliusWishlistPlugin\Repository\WishlistRepositoryInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\ProductInterface; | ||
|
||
final class AddProductToSelectedWishlistHandlerSpec extends ObjectBehavior | ||
{ | ||
public function let( | ||
WishlistProductFactoryInterface $wishlistProductFactory, | ||
WishlistRepositoryInterface $wishlistRepository | ||
): void { | ||
$this->beConstructedWith( | ||
$wishlistProductFactory, | ||
$wishlistRepository | ||
); | ||
} | ||
|
||
public function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(AddProductToSelectedWishlistHandler::class); | ||
} | ||
|
||
public function it_adds_product_to_wishlist_if_product_is_found( | ||
AddProductToSelectedWishlistInterface $addProductToSelectedWishlist, | ||
ProductInterface $product, | ||
WishlistInterface $wishlist, | ||
WishlistProductFactoryInterface $wishlistProductFactory, | ||
WishlistProductInterface $wishlistProduct, | ||
WishlistRepositoryInterface $wishlistRepository | ||
): void | ||
{ | ||
$addProductToSelectedWishlist->getProduct()->willReturn($product); | ||
$addProductToSelectedWishlist->getWishlist()->willReturn($wishlist); | ||
|
||
$wishlistProductFactory->createForWishlistAndProduct($wishlist, $product)->willReturn($wishlistProduct); | ||
|
||
$wishlist->addWishlistProduct($wishlistProduct)->shouldBeCalled(); | ||
$wishlistRepository->add($wishlist)->shouldBeCalled(); | ||
|
||
$this->__invoke($addProductToSelectedWishlist); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
spec/CommandHandler/Wishlist/AddProductToWishlistHandlerSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\SyliusWishlistPlugin\CommandHandler\Wishlist; | ||
|
||
use BitBag\SyliusWishlistPlugin\Command\Wishlist\AddProductToWishlist; | ||
use BitBag\SyliusWishlistPlugin\Command\Wishlist\WishlistTokenValueAwareInterface; | ||
use BitBag\SyliusWishlistPlugin\CommandHandler\Wishlist\AddProductToWishlistHandler; | ||
use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; | ||
use BitBag\SyliusWishlistPlugin\Entity\WishlistProductInterface; | ||
use BitBag\SyliusWishlistPlugin\Exception\ProductNotFoundException; | ||
use BitBag\SyliusWishlistPlugin\Exception\WishlistNotFoundException; | ||
use BitBag\SyliusWishlistPlugin\Factory\WishlistProductFactoryInterface; | ||
use Doctrine\Persistence\ObjectManager; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\ProductInterface; | ||
use Sylius\Component\Core\Repository\ProductRepositoryInterface; | ||
|
||
final class AddProductToWishlistHandlerSpec extends ObjectBehavior | ||
{ | ||
public function let( | ||
WishlistProductFactoryInterface $wishlistProductFactory, | ||
ProductRepositoryInterface $productRepository, | ||
ObjectManager $wishlistManager | ||
): void { | ||
$this->beConstructedWith( | ||
$wishlistProductFactory, | ||
$productRepository, | ||
$wishlistManager | ||
); | ||
} | ||
|
||
public function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(AddProductToWishlistHandler::class); | ||
} | ||
|
||
public function it_adds_product_to_wishlist( | ||
ProductInterface $product, | ||
WishlistInterface $wishlist, | ||
ProductRepositoryInterface $productRepository, | ||
WishlistProductFactoryInterface $wishlistProductFactory, | ||
WishlistProductInterface $wishlistProduct, | ||
ObjectManager $wishlistManager | ||
): void | ||
{ | ||
$productRepository->find(1)->willReturn($product); | ||
|
||
$wishlistProductFactory->createForWishlistAndProduct($wishlist, $product)->willReturn($wishlistProduct); | ||
$wishlist->addWishlistProduct($wishlistProduct)->shouldBeCalled(); | ||
|
||
$wishlistManager->persist($wishlistProduct)->shouldBeCalled(); | ||
$wishlistManager->flush()->shouldBeCalled(); | ||
|
||
$addProductToWishlist = new AddProductToWishlist(1); | ||
$addProductToWishlist->setWishlist($wishlist->getWrappedObject()); | ||
|
||
$this->__invoke($addProductToWishlist); | ||
} | ||
|
||
public function it_doesnt_add_product_to_wishlist_if_product_isnt_found( | ||
ProductInterface $product, | ||
WishlistInterface $wishlist, | ||
ProductRepositoryInterface $productRepository, | ||
WishlistProductFactoryInterface $wishlistProductFactory, | ||
WishlistProductInterface $wishlistProduct, | ||
ObjectManager $wishlistManager | ||
): void | ||
{ | ||
$productRepository->find(1)->willReturn(null); | ||
|
||
$wishlistProductFactory->createForWishlistAndProduct($wishlist, $product)->shouldNotBeCalled(); | ||
$wishlist->addWishlistProduct($wishlistProduct)->shouldNotBeCalled(); | ||
|
||
$wishlistManager->persist($wishlistProduct)->shouldNotBeCalled(); | ||
$wishlistManager->flush()->shouldNotBeCalled(); | ||
|
||
$addProductToWishlist = new AddProductToWishlist(1); | ||
$addProductToWishlist->setWishlist($wishlist->getWrappedObject()); | ||
|
||
$this | ||
->shouldThrow(ProductNotFoundException::class) | ||
->during('__invoke', [$addProductToWishlist]) | ||
; | ||
} | ||
} |
Oops, something went wrong.