mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Merge branch '1.1' into 1.2
* 1.1: Apply coding standard fixes Point to a LICENSE in current branch Add Sylius/CustomerOrderCancellationPlugin to the lsit of official plugins Lower PHPStan level 2 errors from 222 to 15 Add information about other plugins Document officially supported plugins in the README
This commit is contained in:
commit
7eef78ac0f
63 changed files with 265 additions and 179 deletions
19
README.md
19
README.md
|
|
@ -38,6 +38,23 @@ Community
|
||||||
|
|
||||||
Stay updated by following our [Twitter](https://twitter.com/Sylius) and [Facebook](https://www.facebook.com/SyliusEcommerce/).
|
Stay updated by following our [Twitter](https://twitter.com/Sylius) and [Facebook](https://www.facebook.com/SyliusEcommerce/).
|
||||||
|
|
||||||
|
Official plugins
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This is the list of oficially supported Sylius plugins:
|
||||||
|
|
||||||
|
- [Shop API Plugin](https://github.com/Sylius/SyliusShopApiPlugin) -
|
||||||
|
provides customer-level API for the shop functionalities
|
||||||
|
- [Admin Order Creation Plugin](https://github.com/Sylius/AdminOrderCreationPlugin) -
|
||||||
|
allows to create orders directly from the administrator panel
|
||||||
|
- [Customer Reorder Plugin](https://github.com/Sylius/CustomerReorderPlugin) -
|
||||||
|
allows customer to copy items from the already placed order to the current cart
|
||||||
|
- [Customer Order Cancellation Plugin](https://github.com/Sylius/CustomerOrderCancellationPlugin) -
|
||||||
|
allows customer to cancel a placed order which has not been processed yet
|
||||||
|
|
||||||
|
You can find other plugins on [our ecosystem website](https://sylius.com/plugins/) or by looking for
|
||||||
|
[packages marked as *sylius-plugin*](https://packagist.org/explore/?type=sylius-plugin).
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|
@ -46,7 +63,7 @@ Would like to help us and build the most developer-friendly eCommerce platform?
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Sylius is completely free and released under the [MIT License](https://github.com/Sylius/Sylius/blob/master/LICENSE).
|
Sylius is completely free and released under the [MIT License](https://github.com/Sylius/Sylius/blob/1.1/LICENSE).
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
-------
|
-------
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ parameters:
|
||||||
- '/Call to an undefined method Faker\\Generator::/'
|
- '/Call to an undefined method Faker\\Generator::/'
|
||||||
- '/Access to an undefined property Faker\\Generator::/'
|
- '/Access to an undefined property Faker\\Generator::/'
|
||||||
- '/Method Mockery\\MockInterface::shouldReceive\(\) invoked with 1 parameter, 0 required/'
|
- '/Method Mockery\\MockInterface::shouldReceive\(\) invoked with 1 parameter, 0 required/'
|
||||||
|
- '/Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface/'
|
||||||
|
- '/Call to an undefined method Mockery\\ExpectationInterface|Mockery\\HigherOrderMessage::/'
|
||||||
|
|
||||||
# These packages aren't in require-dev of the global package
|
# These packages aren't in require-dev of the global package
|
||||||
- '/Class Doctrine\\Bundle\\MongoDBBundle/'
|
- '/Class Doctrine\\Bundle\\MongoDBBundle/'
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ namespace Sylius\Behat\Context\Api\Admin;
|
||||||
|
|
||||||
use Behat\Behat\Context\Context;
|
use Behat\Behat\Context\Context;
|
||||||
use Sylius\Component\Core\Model\ProductInterface;
|
use Sylius\Component\Core\Model\ProductInterface;
|
||||||
use Symfony\Component\BrowserKit\Client;
|
|
||||||
use Symfony\Component\BrowserKit\Cookie;
|
use Symfony\Component\BrowserKit\Cookie;
|
||||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Client;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
final class ManagingProductVariantsContext implements Context
|
final class ManagingProductVariantsContext implements Context
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ namespace Sylius\Behat\Context\Api\Admin;
|
||||||
|
|
||||||
use Behat\Behat\Context\Context;
|
use Behat\Behat\Context\Context;
|
||||||
use Sylius\Component\Core\Model\TaxonInterface;
|
use Sylius\Component\Core\Model\TaxonInterface;
|
||||||
use Symfony\Component\BrowserKit\Client;
|
|
||||||
use Symfony\Component\BrowserKit\Cookie;
|
use Symfony\Component\BrowserKit\Cookie;
|
||||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Client;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
final class ManagingTaxonsContext implements Context
|
final class ManagingTaxonsContext implements Context
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,9 @@ final class AdminUserContext implements Context
|
||||||
*/
|
*/
|
||||||
public function thereIsAnAdministratorIdentifiedBy($email, $password = 'sylius')
|
public function thereIsAnAdministratorIdentifiedBy($email, $password = 'sylius')
|
||||||
{
|
{
|
||||||
|
/** @var AdminUserInterface $adminUser */
|
||||||
$adminUser = $this->userFactory->create(['email' => $email, 'password' => $password, 'enabled' => true]);
|
$adminUser = $this->userFactory->create(['email' => $email, 'password' => $password, 'enabled' => true]);
|
||||||
|
|
||||||
$this->userRepository->add($adminUser);
|
$this->userRepository->add($adminUser);
|
||||||
$this->sharedStorage->set('administrator', $adminUser);
|
$this->sharedStorage->set('administrator', $adminUser);
|
||||||
}
|
}
|
||||||
|
|
@ -67,6 +69,7 @@ final class AdminUserContext implements Context
|
||||||
*/
|
*/
|
||||||
public function thereIsAnAdministratorWithName($username)
|
public function thereIsAnAdministratorWithName($username)
|
||||||
{
|
{
|
||||||
|
/** @var AdminUserInterface $adminUser */
|
||||||
$adminUser = $this->userFactory->create(['username' => $username]);
|
$adminUser = $this->userFactory->create(['username' => $username]);
|
||||||
$adminUser->setUsername($username);
|
$adminUser->setUsername($username);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ use Behat\Behat\Context\Context;
|
||||||
use Doctrine\Common\Persistence\ObjectManager;
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
use Sylius\Behat\Service\SharedStorageInterface;
|
use Sylius\Behat\Service\SharedStorageInterface;
|
||||||
use Sylius\Component\Addressing\Model\CountryInterface;
|
use Sylius\Component\Addressing\Model\CountryInterface;
|
||||||
|
use Sylius\Component\Core\Model\AddressInterface;
|
||||||
use Sylius\Component\Core\Model\CustomerInterface;
|
use Sylius\Component\Core\Model\CustomerInterface;
|
||||||
|
use Sylius\Component\Core\Model\ShopUserInterface;
|
||||||
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
|
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
|
||||||
use Sylius\Component\Customer\Model\CustomerGroupInterface;
|
use Sylius\Component\Customer\Model\CustomerGroupInterface;
|
||||||
use Sylius\Component\Resource\Factory\FactoryInterface;
|
use Sylius\Component\Resource\Factory\FactoryInterface;
|
||||||
|
|
@ -190,6 +192,8 @@ final class CustomerContext implements Context
|
||||||
public function thereIsUserIdentifiedByWithAsShippingCountry($email, CountryInterface $country)
|
public function thereIsUserIdentifiedByWithAsShippingCountry($email, CountryInterface $country)
|
||||||
{
|
{
|
||||||
$customer = $this->createCustomerWithUserAccount($email, 'password123', true, 'John', 'Doe');
|
$customer = $this->createCustomerWithUserAccount($email, 'password123', true, 'John', 'Doe');
|
||||||
|
|
||||||
|
/** @var AddressInterface $address */
|
||||||
$address = $this->addressFactory->createNew();
|
$address = $this->addressFactory->createNew();
|
||||||
$address->setCountryCode($country->getCode());
|
$address->setCountryCode($country->getCode());
|
||||||
$address->setCity('Berlin');
|
$address->setCity('Berlin');
|
||||||
|
|
@ -252,7 +256,9 @@ final class CustomerContext implements Context
|
||||||
$lastName = null,
|
$lastName = null,
|
||||||
$role = null
|
$role = null
|
||||||
) {
|
) {
|
||||||
|
/** @var ShopUserInterface $user */
|
||||||
$user = $this->userFactory->createNew();
|
$user = $this->userFactory->createNew();
|
||||||
|
|
||||||
/** @var CustomerInterface $customer */
|
/** @var CustomerInterface $customer */
|
||||||
$customer = $this->customerFactory->createNew();
|
$customer = $this->customerFactory->createNew();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -778,6 +778,7 @@ final class OrderContext implements Context
|
||||||
$customers = [];
|
$customers = [];
|
||||||
|
|
||||||
for ($i = 0; $i < $count; ++$i) {
|
for ($i = 0; $i < $count; ++$i) {
|
||||||
|
/** @var CustomerInterface $customer */
|
||||||
$customer = $this->customerFactory->createNew();
|
$customer = $this->customerFactory->createNew();
|
||||||
$customer->setEmail(sprintf('john%s@doe.com', uniqid()));
|
$customer->setEmail(sprintf('john%s@doe.com', uniqid()));
|
||||||
$customer->setFirstname('John');
|
$customer->setFirstname('John');
|
||||||
|
|
@ -791,14 +792,9 @@ final class OrderContext implements Context
|
||||||
return $customers;
|
return $customers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function getPriceFromString(string $price): int
|
||||||
* @param string $price
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
private function getPriceFromString($price)
|
|
||||||
{
|
{
|
||||||
return (int) round(str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -847,6 +843,7 @@ final class OrderContext implements Context
|
||||||
*/
|
*/
|
||||||
private function addVariantWithPriceToOrder(OrderInterface $order, ProductVariantInterface $variant, $price)
|
private function addVariantWithPriceToOrder(OrderInterface $order, ProductVariantInterface $variant, $price)
|
||||||
{
|
{
|
||||||
|
/** @var OrderItemInterface $item */
|
||||||
$item = $this->orderItemFactory->createNew();
|
$item = $this->orderItemFactory->createNew();
|
||||||
$item->setVariant($variant);
|
$item->setVariant($variant);
|
||||||
$item->setUnitPrice($price);
|
$item->setUnitPrice($price);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ use Sylius\Component\Product\Model\ProductAssociationTypeInterface;
|
||||||
use Sylius\Component\Product\Model\ProductAssociationTypeTranslationInterface;
|
use Sylius\Component\Product\Model\ProductAssociationTypeTranslationInterface;
|
||||||
use Sylius\Component\Product\Repository\ProductAssociationTypeRepositoryInterface;
|
use Sylius\Component\Product\Repository\ProductAssociationTypeRepositoryInterface;
|
||||||
use Sylius\Component\Resource\Factory\FactoryInterface;
|
use Sylius\Component\Resource\Factory\FactoryInterface;
|
||||||
use Sylius\Component\Resource\Model\TranslationInterface;
|
|
||||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||||
|
|
||||||
final class ProductAssociationContext implements Context
|
final class ProductAssociationContext implements Context
|
||||||
|
|
@ -198,10 +197,10 @@ final class ProductAssociationContext implements Context
|
||||||
*/
|
*/
|
||||||
private function addProductAssociationTypeTranslation(
|
private function addProductAssociationTypeTranslation(
|
||||||
ProductAssociationTypeInterface $productAssociationType,
|
ProductAssociationTypeInterface $productAssociationType,
|
||||||
$name,
|
string $name,
|
||||||
$locale
|
string $locale
|
||||||
) {
|
) {
|
||||||
/** @var ProductAssociationTypeTranslationInterface|TranslationInterface $translation */
|
/** @var ProductAssociationTypeTranslationInterface $translation */
|
||||||
$translation = $this->productAssociationTypeTranslationFactory->createNew();
|
$translation = $this->productAssociationTypeTranslationFactory->createNew();
|
||||||
$translation->setLocale($locale);
|
$translation->setLocale($locale);
|
||||||
$translation->setName($name);
|
$translation->setName($name);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ use Sylius\Component\Product\Model\ProductOptionValueInterface;
|
||||||
use Sylius\Component\Product\Model\ProductVariantTranslationInterface;
|
use Sylius\Component\Product\Model\ProductVariantTranslationInterface;
|
||||||
use Sylius\Component\Product\Resolver\ProductVariantResolverInterface;
|
use Sylius\Component\Product\Resolver\ProductVariantResolverInterface;
|
||||||
use Sylius\Component\Resource\Factory\FactoryInterface;
|
use Sylius\Component\Resource\Factory\FactoryInterface;
|
||||||
use Sylius\Component\Resource\Model\TranslationInterface;
|
|
||||||
use Sylius\Component\Shipping\Model\ShippingCategoryInterface;
|
use Sylius\Component\Shipping\Model\ShippingCategoryInterface;
|
||||||
use Sylius\Component\Taxation\Model\TaxCategoryInterface;
|
use Sylius\Component\Taxation\Model\TaxCategoryInterface;
|
||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
|
|
@ -792,14 +791,9 @@ final class ProductContext implements Context
|
||||||
$this->objectManager->flush();
|
$this->objectManager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function getPriceFromString(string $price): int
|
||||||
* @param string $price
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
private function getPriceFromString($price)
|
|
||||||
{
|
{
|
||||||
return (int) round($price * 100, 2);
|
return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -934,9 +928,10 @@ final class ProductContext implements Context
|
||||||
*/
|
*/
|
||||||
private function addProductTranslation(ProductInterface $product, $name, $locale)
|
private function addProductTranslation(ProductInterface $product, $name, $locale)
|
||||||
{
|
{
|
||||||
/** @var ProductTranslationInterface|TranslationInterface $translation */
|
/** @var ProductTranslationInterface $translation */
|
||||||
$translation = $product->getTranslation($locale);
|
$translation = $product->getTranslation($locale);
|
||||||
if ($translation->getLocale() !== $locale) {
|
if ($translation->getLocale() !== $locale) {
|
||||||
|
/** @var ProductTranslationInterface $translation */
|
||||||
$translation = $this->productTranslationFactory->createNew();
|
$translation = $this->productTranslationFactory->createNew();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -954,7 +949,7 @@ final class ProductContext implements Context
|
||||||
*/
|
*/
|
||||||
private function addProductVariantTranslation(ProductVariantInterface $productVariant, $name, $locale)
|
private function addProductVariantTranslation(ProductVariantInterface $productVariant, $name, $locale)
|
||||||
{
|
{
|
||||||
/** @var ProductVariantTranslationInterface|TranslationInterface $translation */
|
/** @var ProductVariantTranslationInterface $translation */
|
||||||
$translation = $this->productVariantTranslationFactory->createNew();
|
$translation = $this->productVariantTranslationFactory->createNew();
|
||||||
$translation->setLocale($locale);
|
$translation->setLocale($locale);
|
||||||
$translation->setName($name);
|
$translation->setName($name);
|
||||||
|
|
|
||||||
|
|
@ -677,6 +677,7 @@ final class PromotionContext implements Context
|
||||||
$discount,
|
$discount,
|
||||||
CustomerGroupInterface $customerGroup
|
CustomerGroupInterface $customerGroup
|
||||||
) {
|
) {
|
||||||
|
/** @var PromotionRuleInterface $rule */
|
||||||
$rule = $this->ruleFactory->createNew();
|
$rule = $this->ruleFactory->createNew();
|
||||||
$rule->setType(CustomerGroupRuleChecker::TYPE);
|
$rule->setType(CustomerGroupRuleChecker::TYPE);
|
||||||
$rule->setConfiguration(['group_code' => $customerGroup->getCode()]);
|
$rule->setConfiguration(['group_code' => $customerGroup->getCode()]);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ use Sylius\Component\Core\Model\ImageInterface;
|
||||||
use Sylius\Component\Core\Model\TaxonInterface;
|
use Sylius\Component\Core\Model\TaxonInterface;
|
||||||
use Sylius\Component\Core\Uploader\ImageUploaderInterface;
|
use Sylius\Component\Core\Uploader\ImageUploaderInterface;
|
||||||
use Sylius\Component\Resource\Factory\FactoryInterface;
|
use Sylius\Component\Resource\Factory\FactoryInterface;
|
||||||
use Sylius\Component\Resource\Model\TranslationInterface;
|
|
||||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||||
use Sylius\Component\Taxonomy\Generator\TaxonSlugGeneratorInterface;
|
use Sylius\Component\Taxonomy\Generator\TaxonSlugGeneratorInterface;
|
||||||
use Sylius\Component\Taxonomy\Model\TaxonTranslationInterface;
|
use Sylius\Component\Taxonomy\Model\TaxonTranslationInterface;
|
||||||
|
|
@ -184,7 +183,7 @@ final class TaxonomyContext implements Context
|
||||||
$taxon = $this->taxonFactory->createNew();
|
$taxon = $this->taxonFactory->createNew();
|
||||||
$taxon->setCode(StringInflector::nameToCode($names['en_US']));
|
$taxon->setCode(StringInflector::nameToCode($names['en_US']));
|
||||||
foreach ($names as $locale => $name) {
|
foreach ($names as $locale => $name) {
|
||||||
/** @var TranslationInterface|TaxonTranslationInterface $taxonTranslation */
|
/** @var TaxonTranslationInterface $taxonTranslation */
|
||||||
$taxonTranslation = $this->taxonTranslationFactory->createNew();
|
$taxonTranslation = $this->taxonTranslationFactory->createNew();
|
||||||
$taxonTranslation->setLocale($locale);
|
$taxonTranslation->setLocale($locale);
|
||||||
$taxonTranslation->setName($name);
|
$taxonTranslation->setName($name);
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ final class CustomerContext implements Context
|
||||||
/** @var CustomerInterface $customer */
|
/** @var CustomerInterface $customer */
|
||||||
$customer = $this->customerRepository->findOneBy(['email' => $email]);
|
$customer = $this->customerRepository->findOneBy(['email' => $email]);
|
||||||
if (null === $customer) {
|
if (null === $customer) {
|
||||||
|
/** @var CustomerInterface $customer */
|
||||||
$customer = $this->customerFactory->createNew();
|
$customer = $this->customerFactory->createNew();
|
||||||
$customer->setEmail($email);
|
$customer->setEmail($email);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,21 +20,23 @@ final class LexicalContext implements Context
|
||||||
/**
|
/**
|
||||||
* @Transform /^"(\-)?(?:€|£|¥|\$)((?:\d+\.)?\d+)"$/
|
* @Transform /^"(\-)?(?:€|£|¥|\$)((?:\d+\.)?\d+)"$/
|
||||||
*/
|
*/
|
||||||
public function getPriceFromString($sign, $price)
|
public function getPriceFromString(string $sign, string $price): int
|
||||||
{
|
{
|
||||||
$this->validatePriceString($price);
|
$this->validatePriceString($price);
|
||||||
|
|
||||||
|
$price = (int) round((float) $price * 100, 2);
|
||||||
|
|
||||||
if ('-' === $sign) {
|
if ('-' === $sign) {
|
||||||
$price *= -1;
|
$price *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) round($price * 100, 2);
|
return $price;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Transform /^"((?:\d+\.)?\d+)%"$/
|
* @Transform /^"((?:\d+\.)?\d+)%"$/
|
||||||
*/
|
*/
|
||||||
public function getPercentageFromString($percentage)
|
public function getPercentageFromString(string $percentage): float
|
||||||
{
|
{
|
||||||
return ((int) $percentage) / 100;
|
return ((int) $percentage) / 100;
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +46,7 @@ final class LexicalContext implements Context
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function validatePriceString($price)
|
private function validatePriceString(string $price): void
|
||||||
{
|
{
|
||||||
if (!(bool) preg_match('/^\d+(?:\.\d{1,2})?$/', $price)) {
|
if (!(bool) preg_match('/^\d+(?:\.\d{1,2})?$/', $price)) {
|
||||||
throw new \InvalidArgumentException('Price string should not have more than 2 decimal digits.');
|
throw new \InvalidArgumentException('Price string should not have more than 2 decimal digits.');
|
||||||
|
|
|
||||||
|
|
@ -151,17 +151,6 @@ final class ManagingPaymentMethodsContext implements Context
|
||||||
$this->notificationChecker->checkNotification('Cannot delete, the payment method is in use.', NotificationType::failure());
|
$this->notificationChecker->checkNotification('Cannot delete, the payment method is in use.', NotificationType::failure());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @When I choose :gatewayName gateway
|
|
||||||
*/
|
|
||||||
public function iChooseGateway($gatewayName)
|
|
||||||
{
|
|
||||||
/** @var CreatePageInterface|UpdatePageInterface $currentPage */
|
|
||||||
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
|
|
||||||
|
|
||||||
$currentPage->chooseGateway($gatewayName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then this payment method :element should be :value
|
* @Then this payment method :element should be :value
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,7 @@ final class ManagingProductAttributesContext implements Context
|
||||||
*/
|
*/
|
||||||
public function theTypeFieldShouldBeDisabled()
|
public function theTypeFieldShouldBeDisabled()
|
||||||
{
|
{
|
||||||
|
/** @var CreatePageInterface|UpdatePageInterface $currentPage */
|
||||||
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
|
||||||
|
|
||||||
Assert::true($currentPage->isTypeDisabled());
|
Assert::true($currentPage->isTypeDisabled());
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,7 @@ final class ManagingProductOptionsContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iAddTheOptionValueWithCodeAndValue($value, $code)
|
public function iAddTheOptionValueWithCodeAndValue($value, $code)
|
||||||
{
|
{
|
||||||
|
/** @var CreatePageInterface|UpdatePageInterface $currentPage */
|
||||||
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
|
||||||
|
|
||||||
$currentPage->addOptionValue($code, $value);
|
$currentPage->addOptionValue($code, $value);
|
||||||
|
|
|
||||||
|
|
@ -115,14 +115,6 @@ final class ManagingProductVariantsContext implements Context
|
||||||
$this->createPage->nameItIn($name, $language);
|
$this->createPage->nameItIn($name, $language);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @When I rename it to :name
|
|
||||||
*/
|
|
||||||
public function iRenameItTo($name)
|
|
||||||
{
|
|
||||||
$this->updatePage->nameIt($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When I add it
|
* @When I add it
|
||||||
* @When I try to add it
|
* @When I try to add it
|
||||||
|
|
@ -418,14 +410,6 @@ final class ManagingProductVariantsContext implements Context
|
||||||
$this->updatePage->saveChanges();
|
$this->updatePage->saveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @When I remove its name
|
|
||||||
*/
|
|
||||||
public function iRemoveItsNameFromTranslation()
|
|
||||||
{
|
|
||||||
$this->updatePage->nameIt('');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then /^inventory of (this variant) should not be tracked$/
|
* @Then /^inventory of (this variant) should not be tracked$/
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ use Sylius\Behat\Page\Admin\Product\IndexPerTaxonPageInterface;
|
||||||
use Sylius\Behat\Page\Admin\Product\UpdateConfigurableProductPageInterface;
|
use Sylius\Behat\Page\Admin\Product\UpdateConfigurableProductPageInterface;
|
||||||
use Sylius\Behat\Page\Admin\Product\UpdateSimpleProductPageInterface;
|
use Sylius\Behat\Page\Admin\Product\UpdateSimpleProductPageInterface;
|
||||||
use Sylius\Behat\Page\Admin\ProductReview\IndexPageInterface as ProductReviewIndexPageInterface;
|
use Sylius\Behat\Page\Admin\ProductReview\IndexPageInterface as ProductReviewIndexPageInterface;
|
||||||
use Sylius\Behat\Page\SymfonyPageInterface;
|
|
||||||
use Sylius\Behat\Service\NotificationCheckerInterface;
|
use Sylius\Behat\Service\NotificationCheckerInterface;
|
||||||
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
|
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
|
||||||
use Sylius\Behat\Service\SharedStorageInterface;
|
use Sylius\Behat\Service\SharedStorageInterface;
|
||||||
|
|
@ -987,7 +986,7 @@ final class ManagingProductsContext implements Context
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return SymfonyPageInterface|IndexPageInterface|IndexPerTaxonPageInterface|CreateSimpleProductPageInterface|CreateConfigurableProductPageInterface|UpdateSimpleProductPageInterface|UpdateConfigurableProductPageInterface
|
* @return IndexPageInterface|IndexPerTaxonPageInterface|CreateSimpleProductPageInterface|CreateConfigurableProductPageInterface|UpdateSimpleProductPageInterface|UpdateConfigurableProductPageInterface
|
||||||
*/
|
*/
|
||||||
private function resolveCurrentPage()
|
private function resolveCurrentPage()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -350,6 +350,7 @@ final class ManagingPromotionsContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iSetItsUsageLimitTo($usageLimit)
|
public function iSetItsUsageLimitTo($usageLimit)
|
||||||
{
|
{
|
||||||
|
/** @var CreatePageInterface|UpdatePageInterface $currentPage */
|
||||||
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
|
||||||
|
|
||||||
$currentPage->fillUsageLimit($usageLimit);
|
$currentPage->fillUsageLimit($usageLimit);
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ namespace Sylius\Behat\Context\Ui\Admin;
|
||||||
|
|
||||||
use Behat\Behat\Context\Context;
|
use Behat\Behat\Context\Context;
|
||||||
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface;
|
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface;
|
||||||
use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface;
|
|
||||||
use Sylius\Behat\Page\Admin\ShippingCategory\CreatePageInterface;
|
use Sylius\Behat\Page\Admin\ShippingCategory\CreatePageInterface;
|
||||||
|
use Sylius\Behat\Page\Admin\ShippingCategory\UpdatePageInterface;
|
||||||
use Sylius\Component\Shipping\Model\ShippingCategoryInterface;
|
use Sylius\Component\Shipping\Model\ShippingCategoryInterface;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ use Behat\Behat\Context\Context;
|
||||||
use Sylius\Behat\Page\Admin\Taxon\CreateForParentPageInterface;
|
use Sylius\Behat\Page\Admin\Taxon\CreateForParentPageInterface;
|
||||||
use Sylius\Behat\Page\Admin\Taxon\CreatePageInterface;
|
use Sylius\Behat\Page\Admin\Taxon\CreatePageInterface;
|
||||||
use Sylius\Behat\Page\Admin\Taxon\UpdatePageInterface;
|
use Sylius\Behat\Page\Admin\Taxon\UpdatePageInterface;
|
||||||
use Sylius\Behat\Page\SymfonyPageInterface;
|
|
||||||
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
|
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
|
||||||
use Sylius\Behat\Service\SharedStorageInterface;
|
use Sylius\Behat\Service\SharedStorageInterface;
|
||||||
use Sylius\Component\Core\Model\TaxonInterface;
|
use Sylius\Component\Core\Model\TaxonInterface;
|
||||||
|
|
@ -408,7 +407,7 @@ final class ManagingTaxonsContext implements Context
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return SymfonyPageInterface|CreatePageInterface|CreateForParentPageInterface|UpdatePageInterface
|
* @return CreatePageInterface|CreateForParentPageInterface|UpdatePageInterface
|
||||||
*/
|
*/
|
||||||
private function resolveCurrentPage()
|
private function resolveCurrentPage()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ namespace Sylius\Behat\Context\Ui\Shop;
|
||||||
|
|
||||||
use Behat\Behat\Context\Context;
|
use Behat\Behat\Context\Context;
|
||||||
use Sylius\Behat\NotificationType;
|
use Sylius\Behat\NotificationType;
|
||||||
use Sylius\Behat\Page\PageInterface;
|
|
||||||
use Sylius\Behat\Page\Shop\Account\ChangePasswordPageInterface;
|
use Sylius\Behat\Page\Shop\Account\ChangePasswordPageInterface;
|
||||||
use Sylius\Behat\Page\Shop\Account\DashboardPageInterface;
|
use Sylius\Behat\Page\Shop\Account\DashboardPageInterface;
|
||||||
use Sylius\Behat\Page\Shop\Account\LoginPageInterface;
|
use Sylius\Behat\Page\Shop\Account\LoginPageInterface;
|
||||||
|
|
@ -170,11 +169,10 @@ final class AccountContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iShouldBeNotifiedThatElementIsRequired($element)
|
public function iShouldBeNotifiedThatElementIsRequired($element)
|
||||||
{
|
{
|
||||||
$this->assertFieldValidationMessage(
|
Assert::true($this->profileUpdatePage->checkValidationMessageFor(
|
||||||
$this->profileUpdatePage,
|
|
||||||
StringInflector::nameToCode($element),
|
StringInflector::nameToCode($element),
|
||||||
sprintf('Please enter your %s.', $element)
|
sprintf('Please enter your %s.', $element)
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -182,11 +180,10 @@ final class AccountContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iShouldBeNotifiedThatElementIsInvalid($element)
|
public function iShouldBeNotifiedThatElementIsInvalid($element)
|
||||||
{
|
{
|
||||||
$this->assertFieldValidationMessage(
|
Assert::true($this->profileUpdatePage->checkValidationMessageFor(
|
||||||
$this->profileUpdatePage,
|
|
||||||
StringInflector::nameToCode($element),
|
StringInflector::nameToCode($element),
|
||||||
sprintf('This %s is invalid.', $element)
|
sprintf('This %s is invalid.', $element)
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -194,7 +191,7 @@ final class AccountContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iShouldBeNotifiedThatTheEmailIsAlreadyUsed()
|
public function iShouldBeNotifiedThatTheEmailIsAlreadyUsed()
|
||||||
{
|
{
|
||||||
$this->assertFieldValidationMessage($this->profileUpdatePage, 'email', 'This email is already used.');
|
Assert::true($this->profileUpdatePage->checkValidationMessageFor('email', 'This email is already used.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -252,11 +249,10 @@ final class AccountContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iShouldBeNotifiedThatProvidedPasswordIsDifferentThanTheCurrentOne()
|
public function iShouldBeNotifiedThatProvidedPasswordIsDifferentThanTheCurrentOne()
|
||||||
{
|
{
|
||||||
$this->assertFieldValidationMessage(
|
Assert::true($this->changePasswordPage->checkValidationMessageFor(
|
||||||
$this->changePasswordPage,
|
|
||||||
'current_password',
|
'current_password',
|
||||||
'Provided password is different than the current one.'
|
'Provided password is different than the current one.'
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -264,11 +260,10 @@ final class AccountContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iShouldBeNotifiedThatTheEnteredPasswordsDoNotMatch()
|
public function iShouldBeNotifiedThatTheEnteredPasswordsDoNotMatch()
|
||||||
{
|
{
|
||||||
$this->assertFieldValidationMessage(
|
Assert::true($this->changePasswordPage->checkValidationMessageFor(
|
||||||
$this->changePasswordPage,
|
|
||||||
'new_password',
|
'new_password',
|
||||||
'The entered passwords don\'t match'
|
'The entered passwords don\'t match'
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -276,11 +271,10 @@ final class AccountContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iShouldBeNotifiedThatThePasswordShouldBeAtLeastCharactersLong()
|
public function iShouldBeNotifiedThatThePasswordShouldBeAtLeastCharactersLong()
|
||||||
{
|
{
|
||||||
$this->assertFieldValidationMessage(
|
Assert::true($this->changePasswordPage->checkValidationMessageFor(
|
||||||
$this->changePasswordPage,
|
|
||||||
'new_password',
|
'new_password',
|
||||||
'Password must be at least 4 characters long.'
|
'Password must be at least 4 characters long.'
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -452,14 +446,4 @@ final class AccountContext implements Context
|
||||||
{
|
{
|
||||||
$this->loginPage->tryToOpen();
|
$this->loginPage->tryToOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param PageInterface $page
|
|
||||||
* @param string $element
|
|
||||||
* @param string $expectedMessage
|
|
||||||
*/
|
|
||||||
private function assertFieldValidationMessage(PageInterface $page, $element, $expectedMessage)
|
|
||||||
{
|
|
||||||
Assert::true($page->checkValidationMessageFor($element, $expectedMessage));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -423,13 +423,8 @@ final class CartContext implements Context
|
||||||
Assert::same($this->summaryPage->getCartTotal(), $total);
|
Assert::same($this->summaryPage->getCartTotal(), $total);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function getPriceFromString(string $price): int
|
||||||
* @param string $price
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
private function getPriceFromString($price)
|
|
||||||
{
|
{
|
||||||
return (int) round(str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ namespace Sylius\Behat\Context\Ui\Shop;
|
||||||
|
|
||||||
use Behat\Behat\Context\Context;
|
use Behat\Behat\Context\Context;
|
||||||
use Sylius\Behat\NotificationType;
|
use Sylius\Behat\NotificationType;
|
||||||
use Sylius\Behat\Page\PageInterface;
|
|
||||||
use Sylius\Behat\Page\Shop\Contact\ContactPageInterface;
|
use Sylius\Behat\Page\Shop\Contact\ContactPageInterface;
|
||||||
use Sylius\Behat\Service\NotificationCheckerInterface;
|
use Sylius\Behat\Service\NotificationCheckerInterface;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
@ -95,11 +94,7 @@ final class ContactContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iShouldBeNotifiedThatElementIsRequired($element)
|
public function iShouldBeNotifiedThatElementIsRequired($element)
|
||||||
{
|
{
|
||||||
$this->assertFieldValidationMessage(
|
Assert::same($this->contactPage->getValidationMessageFor($element), sprintf('Please enter your %s.', $element));
|
||||||
$this->contactPage,
|
|
||||||
$element,
|
|
||||||
sprintf('Please enter your %s.', $element)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -107,11 +102,7 @@ final class ContactContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iShouldBeNotifiedThatEmailIsInvalid()
|
public function iShouldBeNotifiedThatEmailIsInvalid()
|
||||||
{
|
{
|
||||||
$this->assertFieldValidationMessage(
|
Assert::same($this->contactPage->getValidationMessageFor('email'), 'This email is invalid.');
|
||||||
$this->contactPage,
|
|
||||||
'email',
|
|
||||||
'This email is invalid.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -124,14 +115,4 @@ final class ContactContext implements Context
|
||||||
NotificationType::failure()
|
NotificationType::failure()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param PageInterface $page
|
|
||||||
* @param string $element
|
|
||||||
* @param string $expectedMessage
|
|
||||||
*/
|
|
||||||
private function assertFieldValidationMessage(PageInterface $page, $element, $expectedMessage)
|
|
||||||
{
|
|
||||||
Assert::same($page->getValidationMessageFor($element), $expectedMessage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use Behat\Behat\Context\Context;
|
||||||
use Sylius\Behat\Page\Admin\Customer\ShowPageInterface;
|
use Sylius\Behat\Page\Admin\Customer\ShowPageInterface;
|
||||||
use Sylius\Behat\Page\Shop\HomePageInterface;
|
use Sylius\Behat\Page\Shop\HomePageInterface;
|
||||||
use Sylius\Behat\Service\SharedStorageInterface;
|
use Sylius\Behat\Service\SharedStorageInterface;
|
||||||
|
use Sylius\Component\Core\Model\ShopUserInterface;
|
||||||
use Sylius\Component\User\Repository\UserRepositoryInterface;
|
use Sylius\Component\User\Repository\UserRepositoryInterface;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
|
|
@ -73,6 +74,7 @@ final class UserContext implements Context
|
||||||
*/
|
*/
|
||||||
public function iDeleteAccount($email)
|
public function iDeleteAccount($email)
|
||||||
{
|
{
|
||||||
|
/** @var ShopUserInterface $user */
|
||||||
$user = $this->userRepository->findOneByEmail($email);
|
$user = $this->userRepository->findOneByEmail($email);
|
||||||
|
|
||||||
$this->sharedStorage->set('deleted_user', $user);
|
$this->sharedStorage->set('deleted_user', $user);
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,11 @@ interface CreatePageInterface extends BaseCreatePageInterface
|
||||||
*/
|
*/
|
||||||
public function hasCheckedCreateOption();
|
public function hasCheckedCreateOption();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasCreateOption();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,12 @@ interface UpdatePageInterface extends BaseUpdatePageInterface
|
||||||
* @param AddressInterface $address
|
* @param AddressInterface $address
|
||||||
*/
|
*/
|
||||||
public function specifyBillingAddress(AddressInterface $address);
|
public function specifyBillingAddress(AddressInterface $address);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $element
|
||||||
|
* @param string $message
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function checkValidationMessageFor($element, $message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,16 @@ use Sylius\Behat\Page\Admin\Crud\CreatePageInterface as BaseCreatePageInteface;
|
||||||
|
|
||||||
interface CreatePageInterface extends BaseCreatePageInteface
|
interface CreatePageInterface extends BaseCreatePageInteface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param string $code
|
||||||
|
*/
|
||||||
|
public function specifyCode($code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public function nameIt($name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $description
|
* @param string $description
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ namespace Sylius\Behat\Page\Admin\ShippingCategory;
|
||||||
|
|
||||||
use Sylius\Behat\Behaviour\ChecksCodeImmutability;
|
use Sylius\Behat\Behaviour\ChecksCodeImmutability;
|
||||||
use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage;
|
use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage;
|
||||||
use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface;
|
|
||||||
|
|
||||||
class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Sylius package.
|
||||||
|
*
|
||||||
|
* (c) Paweł Jędrzejewski
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Sylius\Behat\Page\Admin\ShippingCategory;
|
||||||
|
|
||||||
|
use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface as BaseUpdatePageInteface;
|
||||||
|
|
||||||
|
interface UpdatePageInterface extends BaseUpdatePageInteface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isCodeDisabled();
|
||||||
|
}
|
||||||
|
|
@ -133,7 +133,7 @@ abstract class Page implements PageInterface
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return NodeElement
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getParameter($name)
|
protected function getParameter($name)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -318,13 +318,8 @@ class SummaryPage extends SymfonyPage implements SummaryPageInterface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function getPriceFromString(string $price): int
|
||||||
* @param string $price
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
private function getPriceFromString($price)
|
|
||||||
{
|
{
|
||||||
return (int) round(str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -401,12 +401,7 @@ class CompletePage extends SymfonyPage implements CompletePageInterface
|
||||||
return strtoupper(Intl::getRegionBundle()->getCountryName($countryCode, 'en'));
|
return strtoupper(Intl::getRegionBundle()->getCountryName($countryCode, 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function getPriceFromString(string $price): int
|
||||||
* @param string $price
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
private function getPriceFromString($price): int
|
|
||||||
{
|
{
|
||||||
return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Sylius\Behat\Page\Shop\Product;
|
namespace Sylius\Behat\Page\Shop\Product;
|
||||||
|
|
||||||
interface IndexPageInterface
|
use Sylius\Behat\Page\PageInterface;
|
||||||
|
|
||||||
|
interface IndexPageInterface extends PageInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,17 @@ final class CountryChoiceTypeTest extends TypeTestCase
|
||||||
{
|
{
|
||||||
$this->countryRepository = $this->prophesize(RepositoryInterface::class);
|
$this->countryRepository = $this->prophesize(RepositoryInterface::class);
|
||||||
|
|
||||||
$this->france = $this->prophesize(CountryInterface::class);
|
/** @var ProphecyInterface|CountryInterface $france */
|
||||||
$this->france->getCode()->willReturn('FR');
|
$france = $this->prophesize(CountryInterface::class);
|
||||||
$this->france->getName()->willReturn('France');
|
$france->getCode()->willReturn('FR');
|
||||||
|
$france->getName()->willReturn('France');
|
||||||
|
$this->france = $france;
|
||||||
|
|
||||||
$this->poland = $this->prophesize(CountryInterface::class);
|
/** @var ProphecyInterface|CountryInterface $poland */
|
||||||
$this->poland->getCode()->willReturn('PL');
|
$poland = $this->prophesize(CountryInterface::class);
|
||||||
$this->poland->getName()->willReturn('Poland');
|
$poland->getCode()->willReturn('PL');
|
||||||
|
$poland->getName()->willReturn('Poland');
|
||||||
|
$this->poland = $poland;
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ declare(strict_types=1);
|
||||||
namespace Sylius\Bundle\AddressingBundle\Validator\Constraints;
|
namespace Sylius\Bundle\AddressingBundle\Validator\Constraints;
|
||||||
|
|
||||||
use Sylius\Component\Addressing\Model\AddressInterface;
|
use Sylius\Component\Addressing\Model\AddressInterface;
|
||||||
|
use Sylius\Component\Addressing\Model\CountryInterface;
|
||||||
|
use Sylius\Component\Addressing\Model\ProvinceInterface;
|
||||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\ConstraintValidator;
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
|
@ -76,7 +78,11 @@ class ProvinceAddressConstraintValidator extends ConstraintValidator
|
||||||
protected function isProvinceValid(AddressInterface $address): bool
|
protected function isProvinceValid(AddressInterface $address): bool
|
||||||
{
|
{
|
||||||
$countryCode = $address->getCountryCode();
|
$countryCode = $address->getCountryCode();
|
||||||
if (null === $country = $this->countryRepository->findOneBy(['code' => $countryCode])) {
|
|
||||||
|
/** @var CountryInterface|null $country */
|
||||||
|
$country = $this->countryRepository->findOneBy(['code' => $countryCode]);
|
||||||
|
|
||||||
|
if (null === $country) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,7 +94,10 @@ class ProvinceAddressConstraintValidator extends ConstraintValidator
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $province = $this->provinceRepository->findOneBy(['code' => $address->getProvinceCode()])) {
|
/** @var ProvinceInterface|null $province */
|
||||||
|
$province = $this->provinceRepository->findOneBy(['code' => $address->getProvinceCode()]);
|
||||||
|
|
||||||
|
if (null === $province) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ use GuzzleHttp\Exception\ConnectException;
|
||||||
use Http\Message\MessageFactory;
|
use Http\Message\MessageFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Prophecy\Argument;
|
use Prophecy\Argument;
|
||||||
|
use Prophecy\Prophecy\ProphecyInterface;
|
||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
|
@ -28,12 +29,12 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
final class NotificationControllerTest extends TestCase
|
final class NotificationControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var ClientInterface
|
* @var ProphecyInterface|ClientInterface
|
||||||
*/
|
*/
|
||||||
private $client;
|
private $client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var MessageFactory
|
* @var ProphecyInterface|MessageFactory
|
||||||
*/
|
*/
|
||||||
private $messageFactory;
|
private $messageFactory;
|
||||||
|
|
||||||
|
|
@ -52,7 +53,7 @@ final class NotificationControllerTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function it_returns_an_empty_json_response_upon_client_exception(): void
|
public function it_returns_an_empty_json_response_upon_client_exception(): void
|
||||||
{
|
{
|
||||||
$this->messageFactory->createRequest(Argument::cetera())
|
$this->messageFactory->createRequest(Argument::any(), Argument::cetera())
|
||||||
->willReturn($this->prophesize(RequestInterface::class)->reveal())
|
->willReturn($this->prophesize(RequestInterface::class)->reveal())
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -71,13 +72,15 @@ final class NotificationControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
$content = json_encode(['version' => '9001']);
|
$content = json_encode(['version' => '9001']);
|
||||||
|
|
||||||
$this->messageFactory->createRequest(Argument::cetera())
|
$this->messageFactory->createRequest(Argument::any(), Argument::cetera())
|
||||||
->willReturn($this->prophesize(RequestInterface::class)->reveal())
|
->willReturn($this->prophesize(RequestInterface::class)->reveal())
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/** @var ProphecyInterface|StreamInterface $stream */
|
||||||
$stream = $this->prophesize(StreamInterface::class);
|
$stream = $this->prophesize(StreamInterface::class);
|
||||||
$stream->getContents()->willReturn($content);
|
$stream->getContents()->willReturn($content);
|
||||||
|
|
||||||
|
/** @var ProphecyInterface|ResponseInterface $externalResponse */
|
||||||
$externalResponse = $this->prophesize(ResponseInterface::class);
|
$externalResponse = $this->prophesize(ResponseInterface::class);
|
||||||
$externalResponse->getBody()->willReturn($stream->reveal());
|
$externalResponse->getBody()->willReturn($stream->reveal());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ final class LoadMetadataSubscriber implements EventSubscriber
|
||||||
ClassMetadataInfo $metadata,
|
ClassMetadataInfo $metadata,
|
||||||
ClassMetadataFactory $metadataFactory
|
ClassMetadataFactory $metadataFactory
|
||||||
): void {
|
): void {
|
||||||
|
/** @var ClassMetadataInfo $targetEntityMetadata */
|
||||||
$targetEntityMetadata = $metadataFactory->getMetadataFor($subjectClass);
|
$targetEntityMetadata = $metadataFactory->getMetadataFor($subjectClass);
|
||||||
$subjectMapping = [
|
$subjectMapping = [
|
||||||
'fieldName' => 'subject',
|
'fieldName' => 'subject',
|
||||||
|
|
@ -97,6 +98,7 @@ final class LoadMetadataSubscriber implements EventSubscriber
|
||||||
ClassMetadataInfo $metadata,
|
ClassMetadataInfo $metadata,
|
||||||
ClassMetadataFactory $metadataFactory
|
ClassMetadataFactory $metadataFactory
|
||||||
): void {
|
): void {
|
||||||
|
/** @var ClassMetadataInfo $attributeMetadata */
|
||||||
$attributeMetadata = $metadataFactory->getMetadataFor($attributeClass);
|
$attributeMetadata = $metadataFactory->getMetadataFor($attributeClass);
|
||||||
$attributeMapping = [
|
$attributeMapping = [
|
||||||
'fieldName' => 'attribute',
|
'fieldName' => 'attribute',
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Sylius\Bundle\CoreBundle\Command;
|
namespace Sylius\Bundle\CoreBundle\Command;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Sylius\Bundle\CoreBundle\Installer\Executor\CommandExecutor;
|
use Sylius\Bundle\CoreBundle\Installer\Executor\CommandExecutor;
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
use Symfony\Component\Console\Helper\ProgressBar;
|
use Symfony\Component\Console\Helper\ProgressBar;
|
||||||
|
|
@ -59,7 +60,7 @@ abstract class AbstractInstallCommand extends ContainerAwareCommand
|
||||||
*/
|
*/
|
||||||
protected function getEnvironment(): string
|
protected function getEnvironment(): string
|
||||||
{
|
{
|
||||||
return $this->get('kernel')->getEnvironment();
|
return (string) $this->getContainer()->getParameter('kernel.environment');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -67,7 +68,7 @@ abstract class AbstractInstallCommand extends ContainerAwareCommand
|
||||||
*/
|
*/
|
||||||
protected function isDebug(): bool
|
protected function isDebug(): bool
|
||||||
{
|
{
|
||||||
return $this->get('kernel')->isDebug();
|
return (bool) $this->getContainer()->getParameter('kernel.debug');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -126,7 +127,9 @@ abstract class AbstractInstallCommand extends ContainerAwareCommand
|
||||||
|
|
||||||
// PDO does not always close the connection after Doctrine commands.
|
// PDO does not always close the connection after Doctrine commands.
|
||||||
// See https://github.com/symfony/symfony/issues/11750.
|
// See https://github.com/symfony/symfony/issues/11750.
|
||||||
$this->get('doctrine')->getManager()->getConnection()->close();
|
/** @var EntityManagerInterface $entityManager */
|
||||||
|
$entityManager = $this->getContainer()->get('doctrine')->getManager();
|
||||||
|
$entityManager->getConnection()->close();
|
||||||
|
|
||||||
$progress->advance();
|
$progress->advance();
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +143,7 @@ abstract class AbstractInstallCommand extends ContainerAwareCommand
|
||||||
*/
|
*/
|
||||||
protected function ensureDirectoryExistsAndIsWritable(string $directory, OutputInterface $output): void
|
protected function ensureDirectoryExistsAndIsWritable(string $directory, OutputInterface $output): void
|
||||||
{
|
{
|
||||||
$checker = $this->get('sylius.installer.checker.command_directory');
|
$checker = $this->getContainer()->get('sylius.installer.checker.command_directory');
|
||||||
$checker->setCommandName($this->getName());
|
$checker->setCommandName($this->getName());
|
||||||
|
|
||||||
$checker->ensureDirectoryExists($directory, $output);
|
$checker->ensureDirectoryExists($directory, $output);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ EOT
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): void
|
protected function execute(InputInterface $input, OutputInterface $output): void
|
||||||
{
|
{
|
||||||
$fulfilled = $this->get('sylius.installer.checker.sylius_requirements')->check($input, $output);
|
$fulfilled = $this->getContainer()->get('sylius.installer.checker.sylius_requirements')->check($input, $output);
|
||||||
|
|
||||||
if (!$fulfilled) {
|
if (!$fulfilled) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ EOT
|
||||||
));
|
));
|
||||||
|
|
||||||
$commands = $this
|
$commands = $this
|
||||||
|
->getContainer()
|
||||||
->get('sylius.commands_provider.database_setup')
|
->get('sylius.commands_provider.database_setup')
|
||||||
->getCommands($input, $output, $this->getHelper('question'))
|
->getCommands($input, $output, $this->getHelper('question'))
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@ EOT
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): void
|
protected function execute(InputInterface $input, OutputInterface $output): void
|
||||||
{
|
{
|
||||||
$currency = $this->get('sylius.setup.currency')->setup($input, $output, $this->getHelper('question'));
|
$currency = $this->getContainer()->get('sylius.setup.currency')->setup($input, $output, $this->getHelper('question'));
|
||||||
$locale = $this->get('sylius.setup.locale')->setup($input, $output);
|
$locale = $this->getContainer()->get('sylius.setup.locale')->setup($input, $output);
|
||||||
$this->get('sylius.setup.channel')->setup($locale, $currency);
|
$this->getContainer()->get('sylius.setup.channel')->setup($locale, $currency);
|
||||||
$this->setupAdministratorUser($input, $output, $locale->getCode());
|
$this->setupAdministratorUser($input, $output, $locale->getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,8 +63,8 @@ EOT
|
||||||
$outputStyle = new SymfonyStyle($input, $output);
|
$outputStyle = new SymfonyStyle($input, $output);
|
||||||
$outputStyle->writeln('Create your administrator account.');
|
$outputStyle->writeln('Create your administrator account.');
|
||||||
|
|
||||||
$userManager = $this->get('sylius.manager.admin_user');
|
$userManager = $this->getContainer()->get('sylius.manager.admin_user');
|
||||||
$userFactory = $this->get('sylius.factory.admin_user');
|
$userFactory = $this->getContainer()->get('sylius.factory.admin_user');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$user = $this->configureNewUser($userFactory->createNew(), $input, $output);
|
$user = $this->configureNewUser($userFactory->createNew(), $input, $output);
|
||||||
|
|
@ -123,7 +123,7 @@ EOT
|
||||||
return (new Question('E-mail: '))
|
return (new Question('E-mail: '))
|
||||||
->setValidator(function ($value) {
|
->setValidator(function ($value) {
|
||||||
/** @var ConstraintViolationListInterface $errors */
|
/** @var ConstraintViolationListInterface $errors */
|
||||||
$errors = $this->get('validator')->validate((string) $value, [new Email(), new NotBlank()]);
|
$errors = $this->getContainer()->get('validator')->validate((string) $value, [new Email(), new NotBlank()]);
|
||||||
foreach ($errors as $error) {
|
foreach ($errors as $error) {
|
||||||
throw new \DomainException($error->getMessage());
|
throw new \DomainException($error->getMessage());
|
||||||
}
|
}
|
||||||
|
|
@ -191,7 +191,7 @@ EOT
|
||||||
* @param InputInterface $input
|
* @param InputInterface $input
|
||||||
* @param OutputInterface $output
|
* @param OutputInterface $output
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getAdministratorPassword(InputInterface $input, OutputInterface $output): string
|
private function getAdministratorPassword(InputInterface $input, OutputInterface $output): string
|
||||||
{
|
{
|
||||||
|
|
@ -221,7 +221,7 @@ EOT
|
||||||
{
|
{
|
||||||
return function ($value) {
|
return function ($value) {
|
||||||
/** @var ConstraintViolationListInterface $errors */
|
/** @var ConstraintViolationListInterface $errors */
|
||||||
$errors = $this->get('validator')->validate($value, [new NotBlank()]);
|
$errors = $this->getContainer()->get('validator')->validate($value, [new NotBlank()]);
|
||||||
foreach ($errors as $error) {
|
foreach ($errors as $error) {
|
||||||
throw new \DomainException($error->getMessage());
|
throw new \DomainException($error->getMessage());
|
||||||
}
|
}
|
||||||
|
|
@ -251,6 +251,6 @@ EOT
|
||||||
*/
|
*/
|
||||||
private function getAdminUserRepository(): UserRepositoryInterface
|
private function getAdminUserRepository(): UserRepositoryInterface
|
||||||
{
|
{
|
||||||
return $this->get('sylius.repository.admin_user');
|
return $this->getContainer()->get('sylius.repository.admin_user');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,9 @@ abstract class AbstractResourceFixture implements FixtureInterface
|
||||||
final public function getConfigTreeBuilder(): TreeBuilder
|
final public function getConfigTreeBuilder(): TreeBuilder
|
||||||
{
|
{
|
||||||
$treeBuilder = new TreeBuilder();
|
$treeBuilder = new TreeBuilder();
|
||||||
$optionsNode = $treeBuilder->root($this->getName());
|
|
||||||
|
|
||||||
|
/** @var ArrayNodeDefinition $optionsNode */
|
||||||
|
$optionsNode = $treeBuilder->root($this->getName());
|
||||||
$optionsNode->children()->integerNode('random')->min(0)->defaultValue(0);
|
$optionsNode->children()->integerNode('random')->min(0)->defaultValue(0);
|
||||||
|
|
||||||
/** @var ArrayNodeDefinition $resourcesNode */
|
/** @var ArrayNodeDefinition $resourcesNode */
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ use Sylius\Component\Core\Checker\OrderPaymentMethodSelectionRequirementCheckerI
|
||||||
use Sylius\Component\Core\Checker\OrderShippingMethodSelectionRequirementCheckerInterface;
|
use Sylius\Component\Core\Checker\OrderShippingMethodSelectionRequirementCheckerInterface;
|
||||||
use Sylius\Component\Core\Model\AddressInterface;
|
use Sylius\Component\Core\Model\AddressInterface;
|
||||||
use Sylius\Component\Core\Model\OrderInterface;
|
use Sylius\Component\Core\Model\OrderInterface;
|
||||||
|
use Sylius\Component\Core\Model\OrderItemInterface;
|
||||||
use Sylius\Component\Core\OrderCheckoutTransitions;
|
use Sylius\Component\Core\OrderCheckoutTransitions;
|
||||||
use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface;
|
use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface;
|
||||||
use Sylius\Component\Core\Repository\ShippingMethodRepositoryInterface;
|
use Sylius\Component\Core\Repository\ShippingMethodRepositoryInterface;
|
||||||
|
|
@ -225,6 +226,7 @@ class OrderFixture extends AbstractFixture
|
||||||
$products = $this->productRepository->findAll();
|
$products = $this->productRepository->findAll();
|
||||||
|
|
||||||
for ($i = 0; $i < $numberOfItems; ++$i) {
|
for ($i = 0; $i < $numberOfItems; ++$i) {
|
||||||
|
/** @var OrderItemInterface $item */
|
||||||
$item = $this->orderItemFactory->createNew();
|
$item = $this->orderItemFactory->createNew();
|
||||||
|
|
||||||
$product = $this->faker->randomElement($products);
|
$product = $this->faker->randomElement($products);
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ final class ProductTaxonToTaxonTransformer implements DataTransformerInterface
|
||||||
$productTaxon = $this->productTaxonRepository->findOneBy(['taxon' => $taxon, 'product' => $this->product]);
|
$productTaxon = $this->productTaxonRepository->findOneBy(['taxon' => $taxon, 'product' => $this->product]);
|
||||||
|
|
||||||
if (null === $productTaxon) {
|
if (null === $productTaxon) {
|
||||||
|
/** @var ProductTaxonInterface $productTaxon */
|
||||||
$productTaxon = $this->productTaxonFactory->createNew();
|
$productTaxon = $this->productTaxonFactory->createNew();
|
||||||
$productTaxon->setProduct($this->product);
|
$productTaxon->setProduct($this->product);
|
||||||
$productTaxon->setTaxon($taxon);
|
$productTaxon->setTaxon($taxon);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Sylius\Bundle\CoreBundle\Form\EventSubscriber;
|
namespace Sylius\Bundle\CoreBundle\Form\EventSubscriber;
|
||||||
|
|
||||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
use Sylius\Component\Core\Model\CustomerInterface;
|
||||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
||||||
|
|
@ -62,6 +62,8 @@ final class CustomerRegistrationFormSubscriber implements EventSubscriberInterfa
|
||||||
if (!isset($rawData['email']) || empty($rawData['email'])) {
|
if (!isset($rawData['email']) || empty($rawData['email'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var CustomerInterface|null $existingCustomer */
|
||||||
$existingCustomer = $this->customerRepository->findOneBy(['email' => $rawData['email']]);
|
$existingCustomer = $this->customerRepository->findOneBy(['email' => $rawData['email']]);
|
||||||
if (null === $existingCustomer || null !== $existingCustomer->getUser()) {
|
if (null === $existingCustomer || null !== $existingCustomer->getUser()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ final class CustomerGuestType extends AbstractResourceType
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var CustomerInterface $customer */
|
||||||
$customer = $this->customerFactory->createNew();
|
$customer = $this->customerFactory->createNew();
|
||||||
$customer->setEmail($data['email']);
|
$customer->setEmail($data['email']);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ namespace Sylius\Bundle\CoreBundle\Installer\Provider;
|
||||||
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Registry;
|
use Doctrine\Bundle\DoctrineBundle\Registry;
|
||||||
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
@ -152,7 +153,7 @@ final class DatabaseSetupCommandsProvider implements DatabaseSetupCommandsProvid
|
||||||
*/
|
*/
|
||||||
private function getDatabaseName(): string
|
private function getDatabaseName(): string
|
||||||
{
|
{
|
||||||
return $this->doctrineRegistry->getManager()->getConnection()->getDatabase();
|
return $this->getEntityManager()->getConnection()->getDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -160,6 +161,11 @@ final class DatabaseSetupCommandsProvider implements DatabaseSetupCommandsProvid
|
||||||
*/
|
*/
|
||||||
private function getSchemaManager(): AbstractSchemaManager
|
private function getSchemaManager(): AbstractSchemaManager
|
||||||
{
|
{
|
||||||
return $this->doctrineRegistry->getManager()->getConnection()->getSchemaManager();
|
return $this->getEntityManager()->getConnection()->getSchemaManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getEntityManager(): EntityManagerInterface
|
||||||
|
{
|
||||||
|
return $this->doctrineRegistry->getManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ final class ExtensionsRequirements extends RequirementCollection
|
||||||
))
|
))
|
||||||
->add(new Requirement(
|
->add(new Requirement(
|
||||||
$translator->trans('sylius.installer.extensions.pcre', []),
|
$translator->trans('sylius.installer.extensions.pcre', []),
|
||||||
defined('PCRE_VERSION') ? ((float) PCRE_VERSION) > 8.0 : false,
|
defined('PCRE_VERSION') ? ((float) substr(PCRE_VERSION, 0, strpos(PCRE_VERSION, ' '))) > 8.0 : false,
|
||||||
true,
|
true,
|
||||||
$translator->trans('sylius.installer.extensions.help', ['%extension%' => 'PCRE (>=8.0)'])
|
$translator->trans('sylius.installer.extensions.help', ['%extension%' => 'PCRE (>=8.0)'])
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ use Sylius\Component\User\Canonicalizer\CanonicalizerInterface;
|
||||||
use Sylius\Component\User\Model\UserOAuthInterface;
|
use Sylius\Component\User\Model\UserOAuthInterface;
|
||||||
use Sylius\Component\User\Repository\UserRepositoryInterface;
|
use Sylius\Component\User\Repository\UserRepositoryInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loading and ad-hoc creation of a user by an OAuth sign-in provider account.
|
* Loading and ad-hoc creation of a user by an OAuth sign-in provider account.
|
||||||
|
|
@ -184,17 +185,20 @@ class UserProvider extends BaseUserProvider implements AccountConnectorInterface
|
||||||
* @param UserInterface $user
|
* @param UserInterface $user
|
||||||
* @param UserResponseInterface $response
|
* @param UserResponseInterface $response
|
||||||
*
|
*
|
||||||
* @return UserInterface
|
* @return SyliusUserInterface
|
||||||
*/
|
*/
|
||||||
private function updateUserByOAuthUserResponse(UserInterface $user, UserResponseInterface $response): UserInterface
|
private function updateUserByOAuthUserResponse(UserInterface $user, UserResponseInterface $response): SyliusUserInterface
|
||||||
{
|
{
|
||||||
|
/** @var SyliusUserInterface $user */
|
||||||
|
Assert::isInstanceOf($user, SyliusUserInterface::class);
|
||||||
|
|
||||||
|
/** @var UserOAuthInterface $oauth */
|
||||||
$oauth = $this->oauthFactory->createNew();
|
$oauth = $this->oauthFactory->createNew();
|
||||||
$oauth->setIdentifier($response->getUsername());
|
$oauth->setIdentifier($response->getUsername());
|
||||||
$oauth->setProvider($response->getResourceOwner()->getName());
|
$oauth->setProvider($response->getResourceOwner()->getName());
|
||||||
$oauth->setAccessToken($response->getAccessToken());
|
$oauth->setAccessToken($response->getAccessToken());
|
||||||
$oauth->setRefreshToken($response->getRefreshToken());
|
$oauth->setRefreshToken($response->getRefreshToken());
|
||||||
|
|
||||||
/** @var SyliusUserInterface $user */
|
|
||||||
$user->addOAuthAccount($oauth);
|
$user->addOAuthAccount($oauth);
|
||||||
|
|
||||||
$this->userManager->persist($user);
|
$this->userManager->persist($user);
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ namespace Sylius\Bundle\CoreBundle\Order\NumberGenerator;
|
||||||
use Doctrine\DBAL\LockMode;
|
use Doctrine\DBAL\LockMode;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Sylius\Bundle\OrderBundle\NumberGenerator\OrderNumberGeneratorInterface;
|
use Sylius\Bundle\OrderBundle\NumberGenerator\OrderNumberGeneratorInterface;
|
||||||
|
use Sylius\Component\Core\Model\OrderSequenceInterface;
|
||||||
use Sylius\Component\Order\Model\OrderInterface;
|
use Sylius\Component\Order\Model\OrderInterface;
|
||||||
use Sylius\Component\Order\Model\OrderSequenceInterface;
|
|
||||||
use Sylius\Component\Resource\Factory\FactoryInterface;
|
use Sylius\Component\Resource\Factory\FactoryInterface;
|
||||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||||
|
|
||||||
|
|
@ -108,6 +108,7 @@ final class SequentialOrderNumberGenerator implements OrderNumberGeneratorInterf
|
||||||
return $sequence;
|
return $sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var OrderSequenceInterface $sequence */
|
||||||
$sequence = $this->sequenceFactory->createNew();
|
$sequence = $this->sequenceFactory->createNew();
|
||||||
$this->sequenceManager->persist($sequence);
|
$this->sequenceManager->persist($sequence);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||||
namespace Sylius\Bundle\CoreBundle\Tests\Form\Type\Taxon;
|
namespace Sylius\Bundle\CoreBundle\Tests\Form\Type\Taxon;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
use Sylius\Bundle\CoreBundle\Form\Type\Taxon\ProductTaxonAutocompleteChoiceType;
|
use Sylius\Bundle\CoreBundle\Form\Type\Taxon\ProductTaxonAutocompleteChoiceType;
|
||||||
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType;
|
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType;
|
||||||
use Sylius\Component\Core\Model\ProductInterface;
|
use Sylius\Component\Core\Model\ProductInterface;
|
||||||
|
|
@ -29,17 +30,17 @@ use Symfony\Component\Form\Test\TypeTestCase;
|
||||||
final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase
|
final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var ServiceRegistryInterface
|
* @var ObjectProphecy|ServiceRegistryInterface
|
||||||
*/
|
*/
|
||||||
private $resourceRepositoryRegistry;
|
private $resourceRepositoryRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FactoryInterface
|
* @var ObjectProphecy|FactoryInterface
|
||||||
*/
|
*/
|
||||||
private $productTaxonFactory;
|
private $productTaxonFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var RepositoryInterface
|
* @var ObjectProphecy|RepositoryInterface
|
||||||
*/
|
*/
|
||||||
private $productTaxonRepository;
|
private $productTaxonRepository;
|
||||||
|
|
||||||
|
|
@ -73,6 +74,7 @@ final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
$taxon = $this->prophesize(TaxonInterface::class);
|
$taxon = $this->prophesize(TaxonInterface::class);
|
||||||
$product = $this->prophesize(ProductInterface::class);
|
$product = $this->prophesize(ProductInterface::class);
|
||||||
|
|
||||||
|
/** @var ObjectProphecy|TaxonRepositoryInterface $taxonRepository */
|
||||||
$taxonRepository = $this->prophesize(TaxonRepositoryInterface::class);
|
$taxonRepository = $this->prophesize(TaxonRepositoryInterface::class);
|
||||||
|
|
||||||
$this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository);
|
$this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository);
|
||||||
|
|
@ -102,6 +104,8 @@ final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
$taxon = $this->prophesize(TaxonInterface::class);
|
$taxon = $this->prophesize(TaxonInterface::class);
|
||||||
$product = $this->prophesize(ProductInterface::class);
|
$product = $this->prophesize(ProductInterface::class);
|
||||||
$productTaxon = $this->prophesize(ProductTaxonInterface::class);
|
$productTaxon = $this->prophesize(ProductTaxonInterface::class);
|
||||||
|
|
||||||
|
/** @var ObjectProphecy|TaxonRepositoryInterface $taxonRepository */
|
||||||
$taxonRepository = $this->prophesize(TaxonRepositoryInterface::class);
|
$taxonRepository = $this->prophesize(TaxonRepositoryInterface::class);
|
||||||
|
|
||||||
$this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository);
|
$this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository);
|
||||||
|
|
@ -126,6 +130,8 @@ final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
{
|
{
|
||||||
$taxon = $this->prophesize(TaxonInterface::class);
|
$taxon = $this->prophesize(TaxonInterface::class);
|
||||||
$product = $this->prophesize(ProductInterface::class);
|
$product = $this->prophesize(ProductInterface::class);
|
||||||
|
|
||||||
|
/** @var ObjectProphecy|TaxonRepositoryInterface $taxonRepository */
|
||||||
$taxonRepository = $this->prophesize(TaxonRepositoryInterface::class);
|
$taxonRepository = $this->prophesize(TaxonRepositoryInterface::class);
|
||||||
|
|
||||||
$this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository);
|
$this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository);
|
||||||
|
|
@ -155,6 +161,7 @@ final class ProductTaxonAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
$product = $this->prophesize(ProductInterface::class);
|
$product = $this->prophesize(ProductInterface::class);
|
||||||
$productTaxon = $this->prophesize(ProductTaxonInterface::class);
|
$productTaxon = $this->prophesize(ProductTaxonInterface::class);
|
||||||
|
|
||||||
|
/** @var ObjectProphecy|TaxonRepositoryInterface $taxonRepository */
|
||||||
$taxonRepository = $this->prophesize(TaxonRepositoryInterface::class);
|
$taxonRepository = $this->prophesize(TaxonRepositoryInterface::class);
|
||||||
|
|
||||||
$this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository);
|
$this->resourceRepositoryRegistry->get('sylius.taxon')->willReturn($taxonRepository);
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ final class RegisteredUserValidator extends ConstraintValidator
|
||||||
/** @var RegisteredUser $constraint */
|
/** @var RegisteredUser $constraint */
|
||||||
Assert::isInstanceOf($constraint, RegisteredUser::class);
|
Assert::isInstanceOf($constraint, RegisteredUser::class);
|
||||||
|
|
||||||
|
/** @var CustomerInterface|null $existingCustomer */
|
||||||
$existingCustomer = $this->customerRepository->findOneBy(['email' => $customer->getEmail()]);
|
$existingCustomer = $this->customerRepository->findOneBy(['email' => $customer->getEmail()]);
|
||||||
if (null !== $existingCustomer && null !== $existingCustomer->getUser()) {
|
if (null !== $existingCustomer && null !== $existingCustomer->getUser()) {
|
||||||
$this->context->buildViolation($constraint->message)->atPath('email')->addViolation();
|
$this->context->buildViolation($constraint->message)->atPath('email')->addViolation();
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ namespace Sylius\Bundle\PayumBundle\Controller;
|
||||||
use FOS\RestBundle\View\View;
|
use FOS\RestBundle\View\View;
|
||||||
use Payum\Core\Model\GatewayConfigInterface;
|
use Payum\Core\Model\GatewayConfigInterface;
|
||||||
use Payum\Core\Payum;
|
use Payum\Core\Payum;
|
||||||
|
use Payum\Core\Request\Generic;
|
||||||
|
use Payum\Core\Request\GetStatusInterface;
|
||||||
use Payum\Core\Security\GenericTokenFactoryInterface;
|
use Payum\Core\Security\GenericTokenFactoryInterface;
|
||||||
use Payum\Core\Security\HttpRequestVerifierInterface;
|
use Payum\Core\Security\HttpRequestVerifierInterface;
|
||||||
use Payum\Core\Security\TokenInterface;
|
use Payum\Core\Security\TokenInterface;
|
||||||
|
|
@ -24,12 +26,14 @@ use Sylius\Bundle\PayumBundle\Factory\ResolveNextRouteFactoryInterface;
|
||||||
use Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactoryInterface;
|
use Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactoryInterface;
|
||||||
use Sylius\Bundle\ResourceBundle\Controller\ViewHandlerInterface;
|
use Sylius\Bundle\ResourceBundle\Controller\ViewHandlerInterface;
|
||||||
use Sylius\Component\Core\Model\OrderInterface;
|
use Sylius\Component\Core\Model\OrderInterface;
|
||||||
|
use Sylius\Component\Core\Model\PaymentInterface;
|
||||||
|
use Sylius\Component\Core\Model\PaymentMethodInterface;
|
||||||
use Sylius\Component\Order\Repository\OrderRepositoryInterface;
|
use Sylius\Component\Order\Repository\OrderRepositoryInterface;
|
||||||
use Sylius\Component\Payment\Model\PaymentInterface;
|
|
||||||
use Sylius\Component\Resource\Metadata\MetadataInterface;
|
use Sylius\Component\Resource\Metadata\MetadataInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\Routing\RouterInterface;
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
|
|
||||||
|
|
@ -124,15 +128,19 @@ final class PayumController
|
||||||
|
|
||||||
$token = $this->getHttpRequestVerifier()->verify($request);
|
$token = $this->getHttpRequestVerifier()->verify($request);
|
||||||
|
|
||||||
|
/** @var Generic|GetStatusInterface $status */
|
||||||
$status = $this->getStatusRequestFactory->createNewWithModel($token);
|
$status = $this->getStatusRequestFactory->createNewWithModel($token);
|
||||||
$this->payum->getGateway($token->getGatewayName())->execute($status);
|
$this->payum->getGateway($token->getGatewayName())->execute($status);
|
||||||
|
|
||||||
$resolveNextRoute = $this->resolveNextRouteRequestFactory->createNewWithModel($status->getFirstModel());
|
$resolveNextRoute = $this->resolveNextRouteRequestFactory->createNewWithModel($status->getFirstModel());
|
||||||
$this->payum->getGateway($token->getGatewayName())->execute($resolveNextRoute);
|
$this->payum->getGateway($token->getGatewayName())->execute($resolveNextRoute);
|
||||||
|
|
||||||
$this->getHttpRequestVerifier()->invalidate($token);
|
$this->getHttpRequestVerifier()->invalidate($token);
|
||||||
|
|
||||||
if (PaymentInterface::STATE_NEW !== $status->getValue()) {
|
if (PaymentInterface::STATE_NEW !== $status->getValue()) {
|
||||||
$request->getSession()->getBag('flashes')->add('info', sprintf('sylius.payment.%s', $status->getValue()));
|
/** @var FlashBagInterface $flashBag */
|
||||||
|
$flashBag = $request->getSession()->getBag('flashes');
|
||||||
|
$flashBag->add('info', sprintf('sylius.payment.%s', $status->getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->viewHandler->handle(
|
return $this->viewHandler->handle(
|
||||||
|
|
@ -153,8 +161,11 @@ final class PayumController
|
||||||
|
|
||||||
private function provideTokenBasedOnPayment(PaymentInterface $payment, array $redirectOptions): TokenInterface
|
private function provideTokenBasedOnPayment(PaymentInterface $payment, array $redirectOptions): TokenInterface
|
||||||
{
|
{
|
||||||
|
/** @var PaymentMethodInterface $paymentMethod */
|
||||||
|
$paymentMethod = $payment->getMethod();
|
||||||
|
|
||||||
/** @var GatewayConfigInterface $gatewayConfig */
|
/** @var GatewayConfigInterface $gatewayConfig */
|
||||||
$gatewayConfig = $payment->getMethod()->getGatewayConfig();
|
$gatewayConfig = $paymentMethod->getGatewayConfig();
|
||||||
|
|
||||||
if (isset($gatewayConfig->getConfig()['use_authorize']) && $gatewayConfig->getConfig()['use_authorize'] == true) {
|
if (isset($gatewayConfig->getConfig()['use_authorize']) && $gatewayConfig->getConfig()['use_authorize'] == true) {
|
||||||
$token = $this->getTokenFactory()->createAuthorizeToken(
|
$token = $this->getTokenFactory()->createAuthorizeToken(
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Sylius\Bundle\ResourceBundle\Form\Type;
|
namespace Sylius\Bundle\ResourceBundle\Form\Type;
|
||||||
|
|
||||||
|
use Sylius\Bundle\ResourceBundle\Form\Builder\DefaultFormBuilderInterface;
|
||||||
use Sylius\Component\Registry\ServiceRegistryInterface;
|
use Sylius\Component\Registry\ServiceRegistryInterface;
|
||||||
use Sylius\Component\Resource\Metadata\RegistryInterface;
|
use Sylius\Component\Resource\Metadata\RegistryInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
|
@ -46,6 +47,8 @@ final class DefaultResourceType extends AbstractType
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$metadata = $this->metadataRegistry->getByClass($options['data_class']);
|
$metadata = $this->metadataRegistry->getByClass($options['data_class']);
|
||||||
|
|
||||||
|
/** @var DefaultFormBuilderInterface $formBuilder */
|
||||||
$formBuilder = $this->formBuilderRegistry->get($metadata->getDriver());
|
$formBuilder = $this->formBuilderRegistry->get($metadata->getDriver());
|
||||||
|
|
||||||
$formBuilder->build($metadata, $builder, $options);
|
$formBuilder->build($metadata, $builder, $options);
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,11 @@ declare(strict_types=1);
|
||||||
namespace Sylius\Bundle\ResourceBundle\Grid\Renderer;
|
namespace Sylius\Bundle\ResourceBundle\Grid\Renderer;
|
||||||
|
|
||||||
use Sylius\Bundle\ResourceBundle\Grid\Parser\OptionsParserInterface;
|
use Sylius\Bundle\ResourceBundle\Grid\Parser\OptionsParserInterface;
|
||||||
|
use Sylius\Bundle\ResourceBundle\Grid\View\ResourceGridView;
|
||||||
use Sylius\Component\Grid\Definition\Action;
|
use Sylius\Component\Grid\Definition\Action;
|
||||||
use Sylius\Component\Grid\Renderer\BulkActionGridRendererInterface;
|
use Sylius\Component\Grid\Renderer\BulkActionGridRendererInterface;
|
||||||
use Sylius\Component\Grid\View\GridViewInterface;
|
use Sylius\Component\Grid\View\GridViewInterface;
|
||||||
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
final class TwigBulkActionGridRenderer implements BulkActionGridRendererInterface
|
final class TwigBulkActionGridRenderer implements BulkActionGridRendererInterface
|
||||||
{
|
{
|
||||||
|
|
@ -55,6 +57,9 @@ final class TwigBulkActionGridRenderer implements BulkActionGridRendererInterfac
|
||||||
*/
|
*/
|
||||||
public function renderBulkAction(GridViewInterface $gridView, Action $bulkAction, $data = null): string
|
public function renderBulkAction(GridViewInterface $gridView, Action $bulkAction, $data = null): string
|
||||||
{
|
{
|
||||||
|
/** @var ResourceGridView $gridView */
|
||||||
|
Assert::isInstanceOf($gridView, ResourceGridView::class);
|
||||||
|
|
||||||
$type = $bulkAction->getType();
|
$type = $bulkAction->getType();
|
||||||
if (!isset($this->bulkActionTemplates[$type])) {
|
if (!isset($this->bulkActionTemplates[$type])) {
|
||||||
throw new \InvalidArgumentException(sprintf('Missing template for bulk action type "%s".', $type));
|
throw new \InvalidArgumentException(sprintf('Missing template for bulk action type "%s".', $type));
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,13 @@ declare(strict_types=1);
|
||||||
namespace Sylius\Bundle\ResourceBundle\Grid\Renderer;
|
namespace Sylius\Bundle\ResourceBundle\Grid\Renderer;
|
||||||
|
|
||||||
use Sylius\Bundle\ResourceBundle\Grid\Parser\OptionsParserInterface;
|
use Sylius\Bundle\ResourceBundle\Grid\Parser\OptionsParserInterface;
|
||||||
|
use Sylius\Bundle\ResourceBundle\Grid\View\ResourceGridView;
|
||||||
use Sylius\Component\Grid\Definition\Action;
|
use Sylius\Component\Grid\Definition\Action;
|
||||||
use Sylius\Component\Grid\Definition\Field;
|
use Sylius\Component\Grid\Definition\Field;
|
||||||
use Sylius\Component\Grid\Definition\Filter;
|
use Sylius\Component\Grid\Definition\Filter;
|
||||||
use Sylius\Component\Grid\Renderer\GridRendererInterface;
|
use Sylius\Component\Grid\Renderer\GridRendererInterface;
|
||||||
use Sylius\Component\Grid\View\GridViewInterface;
|
use Sylius\Component\Grid\View\GridViewInterface;
|
||||||
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
final class TwigGridRenderer implements GridRendererInterface
|
final class TwigGridRenderer implements GridRendererInterface
|
||||||
{
|
{
|
||||||
|
|
@ -81,6 +83,9 @@ final class TwigGridRenderer implements GridRendererInterface
|
||||||
*/
|
*/
|
||||||
public function renderAction(GridViewInterface $gridView, Action $action, $data = null): string
|
public function renderAction(GridViewInterface $gridView, Action $action, $data = null): string
|
||||||
{
|
{
|
||||||
|
/** @var ResourceGridView $gridView */
|
||||||
|
Assert::isInstanceOf($gridView, ResourceGridView::class);
|
||||||
|
|
||||||
$type = $action->getType();
|
$type = $action->getType();
|
||||||
if (!isset($this->actionTemplates[$type])) {
|
if (!isset($this->actionTemplates[$type])) {
|
||||||
throw new \InvalidArgumentException(sprintf('Missing template for action type "%s".', $type));
|
throw new \InvalidArgumentException(sprintf('Missing template for action type "%s".', $type));
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Sylius\Bundle\ResourceBundle\Routing;
|
namespace Sylius\Bundle\ResourceBundle\Routing;
|
||||||
|
|
||||||
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||||
|
|
||||||
|
|
@ -24,6 +25,8 @@ final class Configuration implements ConfigurationInterface
|
||||||
public function getConfigTreeBuilder(): TreeBuilder
|
public function getConfigTreeBuilder(): TreeBuilder
|
||||||
{
|
{
|
||||||
$treeBuilder = new TreeBuilder();
|
$treeBuilder = new TreeBuilder();
|
||||||
|
|
||||||
|
/** @var ArrayNodeDefinition $rootNode */
|
||||||
$rootNode = $treeBuilder->root('routing');
|
$rootNode = $treeBuilder->root('routing');
|
||||||
|
|
||||||
$rootNode
|
$rootNode
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||||
namespace Sylius\Bundle\ResourceBundle\Tests\Command;
|
namespace Sylius\Bundle\ResourceBundle\Tests\Command;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
use Sylius\Bundle\ResourceBundle\Command\DebugResourceCommand;
|
use Sylius\Bundle\ResourceBundle\Command\DebugResourceCommand;
|
||||||
use Sylius\Component\Resource\Metadata\Metadata;
|
use Sylius\Component\Resource\Metadata\Metadata;
|
||||||
use Sylius\Component\Resource\Metadata\MetadataInterface;
|
use Sylius\Component\Resource\Metadata\MetadataInterface;
|
||||||
|
|
@ -23,7 +24,7 @@ use Symfony\Component\Console\Tester\CommandTester;
|
||||||
final class DebugResourceCommandTest extends TestCase
|
final class DebugResourceCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var RegistryInterface
|
* @var ObjectProphecy|RegistryInterface
|
||||||
*/
|
*/
|
||||||
private $registry;
|
private $registry;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||||
namespace Sylius\Bundle\ResourceBundle\Tests\Form\Type;
|
namespace Sylius\Bundle\ResourceBundle\Tests\Form\Type;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType;
|
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType;
|
||||||
use Sylius\Component\Registry\ServiceRegistryInterface;
|
use Sylius\Component\Registry\ServiceRegistryInterface;
|
||||||
use Sylius\Component\Resource\Model\ResourceInterface;
|
use Sylius\Component\Resource\Model\ResourceInterface;
|
||||||
|
|
@ -26,7 +27,7 @@ use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
|
||||||
final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase
|
final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var ServiceRegistryInterface
|
* @var ObjectProphecy|ServiceRegistryInterface
|
||||||
*/
|
*/
|
||||||
private $resourceRepositoryRegistry;
|
private $resourceRepositoryRegistry;
|
||||||
|
|
||||||
|
|
@ -51,6 +52,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
*/
|
*/
|
||||||
public function it_returns_resource_from_its_code(): void
|
public function it_returns_resource_from_its_code(): void
|
||||||
{
|
{
|
||||||
|
/** @var ObjectProphecy|RepositoryInterface $resourceRepository */
|
||||||
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
||||||
$resource = $this->prophesize(ResourceInterface::class);
|
$resource = $this->prophesize(ResourceInterface::class);
|
||||||
|
|
||||||
|
|
@ -73,6 +75,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
*/
|
*/
|
||||||
public function it_returns_resource_from_its_id(): void
|
public function it_returns_resource_from_its_id(): void
|
||||||
{
|
{
|
||||||
|
/** @var ObjectProphecy|RepositoryInterface $resourceRepository */
|
||||||
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
||||||
$resource = $this->prophesize(ResourceInterface::class);
|
$resource = $this->prophesize(ResourceInterface::class);
|
||||||
|
|
||||||
|
|
@ -95,6 +98,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
*/
|
*/
|
||||||
public function it_returns_different_resource_from_its_identifier(): void
|
public function it_returns_different_resource_from_its_identifier(): void
|
||||||
{
|
{
|
||||||
|
/** @var ObjectProphecy|RepositoryInterface $resourceRepository */
|
||||||
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
||||||
$resource = $this->prophesize(ResourceInterface::class);
|
$resource = $this->prophesize(ResourceInterface::class);
|
||||||
|
|
||||||
|
|
@ -117,6 +121,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
*/
|
*/
|
||||||
public function it_has_identifier_as_view_value(): void
|
public function it_has_identifier_as_view_value(): void
|
||||||
{
|
{
|
||||||
|
/** @var ObjectProphecy|RepositoryInterface $resourceRepository */
|
||||||
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
||||||
$resource = $this->prophesize(ResourceInterface::class);
|
$resource = $this->prophesize(ResourceInterface::class);
|
||||||
|
|
||||||
|
|
@ -139,6 +144,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
*/
|
*/
|
||||||
public function it_has_different_view_based_on_passed_configuration(): void
|
public function it_has_different_view_based_on_passed_configuration(): void
|
||||||
{
|
{
|
||||||
|
/** @var ObjectProphecy|RepositoryInterface $resourceRepository */
|
||||||
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
||||||
$resource = $this->prophesize(ResourceInterface::class);
|
$resource = $this->prophesize(ResourceInterface::class);
|
||||||
|
|
||||||
|
|
@ -162,6 +168,7 @@ final class ResourceAutocompleteChoiceTypeTest extends TypeTestCase
|
||||||
*/
|
*/
|
||||||
public function it_returns_collection_of_resources_from_identifiers(): void
|
public function it_returns_collection_of_resources_from_identifiers(): void
|
||||||
{
|
{
|
||||||
|
/** @var ObjectProphecy|RepositoryInterface $resourceRepository */
|
||||||
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
$resourceRepository = $this->prophesize(RepositoryInterface::class);
|
||||||
$mug = $this->prophesize(ResourceInterface::class);
|
$mug = $this->prophesize(ResourceInterface::class);
|
||||||
$book = $this->prophesize(ResourceInterface::class);
|
$book = $this->prophesize(ResourceInterface::class);
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,9 @@ final class ThemeConfiguration implements ConfigurationInterface
|
||||||
public function getConfigTreeBuilder(): TreeBuilder
|
public function getConfigTreeBuilder(): TreeBuilder
|
||||||
{
|
{
|
||||||
$treeBuilder = new TreeBuilder();
|
$treeBuilder = new TreeBuilder();
|
||||||
$rootNodeDefinition = $treeBuilder->root('sylius_theme');
|
|
||||||
|
|
||||||
|
/** @var ArrayNodeDefinition $rootNodeDefinition */
|
||||||
|
$rootNodeDefinition = $treeBuilder->root('sylius_theme');
|
||||||
$rootNodeDefinition->ignoreExtraKeys();
|
$rootNodeDefinition->ignoreExtraKeys();
|
||||||
|
|
||||||
$this->addRequiredNameField($rootNodeDefinition);
|
$this->addRequiredNameField($rootNodeDefinition);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ use Webmozart\Assert\Assert;
|
||||||
class Order extends BaseOrder implements OrderInterface
|
class Order extends BaseOrder implements OrderInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var BaseCustomerInterface
|
* @var CustomerInterface
|
||||||
*/
|
*/
|
||||||
protected $customer;
|
protected $customer;
|
||||||
|
|
||||||
|
|
@ -126,6 +126,8 @@ class Order extends BaseOrder implements OrderInterface
|
||||||
*/
|
*/
|
||||||
public function setCustomer(?BaseCustomerInterface $customer): void
|
public function setCustomer(?BaseCustomerInterface $customer): void
|
||||||
{
|
{
|
||||||
|
Assert::isInstanceOf($customer, CustomerInterface::class);
|
||||||
|
|
||||||
$this->customer = $customer;
|
$this->customer = $customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -270,6 +272,8 @@ class Order extends BaseOrder implements OrderInterface
|
||||||
public function addPayment(BasePaymentInterface $payment): void
|
public function addPayment(BasePaymentInterface $payment): void
|
||||||
{
|
{
|
||||||
/** @var PaymentInterface $payment */
|
/** @var PaymentInterface $payment */
|
||||||
|
Assert::isInstanceOf($payment, PaymentInterface::class);
|
||||||
|
|
||||||
if (!$this->hasPayment($payment)) {
|
if (!$this->hasPayment($payment)) {
|
||||||
$this->payments->add($payment);
|
$this->payments->add($payment);
|
||||||
$payment->setOrder($this);
|
$payment->setOrder($this);
|
||||||
|
|
@ -282,6 +286,8 @@ class Order extends BaseOrder implements OrderInterface
|
||||||
public function removePayment(BasePaymentInterface $payment): void
|
public function removePayment(BasePaymentInterface $payment): void
|
||||||
{
|
{
|
||||||
/** @var PaymentInterface $payment */
|
/** @var PaymentInterface $payment */
|
||||||
|
Assert::isInstanceOf($payment, PaymentInterface::class);
|
||||||
|
|
||||||
if ($this->hasPayment($payment)) {
|
if ($this->hasPayment($payment)) {
|
||||||
$this->payments->removeElement($payment);
|
$this->payments->removeElement($payment);
|
||||||
$payment->setOrder(null);
|
$payment->setOrder(null);
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@ use PhpSpec\ObjectBehavior;
|
||||||
use Sylius\Component\Channel\Model\ChannelInterface;
|
use Sylius\Component\Channel\Model\ChannelInterface;
|
||||||
use Sylius\Component\Core\Model\AddressInterface;
|
use Sylius\Component\Core\Model\AddressInterface;
|
||||||
use Sylius\Component\Core\Model\AdjustmentInterface;
|
use Sylius\Component\Core\Model\AdjustmentInterface;
|
||||||
|
use Sylius\Component\Core\Model\CustomerInterface;
|
||||||
use Sylius\Component\Core\Model\OrderItemInterface;
|
use Sylius\Component\Core\Model\OrderItemInterface;
|
||||||
use Sylius\Component\Core\Model\PaymentInterface;
|
use Sylius\Component\Core\Model\PaymentInterface;
|
||||||
use Sylius\Component\Core\Model\PromotionInterface;
|
use Sylius\Component\Core\Model\PromotionInterface;
|
||||||
use Sylius\Component\Core\Model\ShipmentInterface;
|
use Sylius\Component\Core\Model\ShipmentInterface;
|
||||||
use Sylius\Component\Core\OrderCheckoutStates;
|
use Sylius\Component\Core\OrderCheckoutStates;
|
||||||
use Sylius\Component\Core\OrderShippingStates;
|
use Sylius\Component\Core\OrderShippingStates;
|
||||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
|
||||||
use Sylius\Component\Order\Model\Order as BaseOrder;
|
use Sylius\Component\Order\Model\Order as BaseOrder;
|
||||||
use Sylius\Component\Order\Model\OrderInterface;
|
use Sylius\Component\Order\Model\OrderInterface;
|
||||||
use Sylius\Component\Promotion\Model\PromotionCouponInterface;
|
use Sylius\Component\Promotion\Model\PromotionCouponInterface;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue