Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gift card buy option #1

Draft
wants to merge 4 commits into
base: 0.12.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4" # Always use the lowest version of PHP since a higher version would create actual syntax errors in lower versions
- "8.0" # Always use the lowest version of PHP since a higher version would create actual syntax errors in lower versions

dependencies:
- "highest"
Expand Down Expand Up @@ -68,7 +68,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
Expand Down Expand Up @@ -138,7 +137,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
Expand Down Expand Up @@ -205,7 +203,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
Expand Down Expand Up @@ -271,7 +268,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"type": "sylius-plugin",
"require": {
"php": ">=7.4",
"php": "^8.0",
"ext-filter": "*",
"ext-mbstring": "*",
"api-platform/core": "^2.6",
Expand Down Expand Up @@ -68,8 +68,7 @@
"psalm/plugin-symfony": "^5.0",
"setono/code-quality-pack": "^2.6",
"setono/sylius-behat-pack": "^0.2.2",
"setono/sylius-catalog-promotion-plugin": "^0.4.8 || ^0.5",
"sylius/sylius": "~1.10.14",
"sylius/sylius": "~1.12.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4 || ^6.0",
Expand Down
4 changes: 0 additions & 4 deletions src/DependencyInjection/SetonoSyliusGiftCardExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ public function load(array $configs, ContainerBuilder $container): void
if ($container->hasParameter('kernel.bundles')) {
$bundles = $container->getParameter('kernel.bundles');
Assert::isArray($bundles);

if (array_key_exists('SetonoSyliusCatalogPromotionPlugin', $bundles)) {
$loader->load('services/conditional/catalog_promotion_rule.xml');
}
}
}
}
15 changes: 0 additions & 15 deletions src/Model/OrderItemTrait.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Model/OrderItemUnitTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

trait OrderItemUnitTrait
{
/** @ORM\OneToOne (targetEntity="Setono\SyliusGiftCardPlugin\Model\GiftCardInterface", mappedBy="orderItemUnit") */
/** @ORM\OneToOne (targetEntity="Setono\SyliusGiftCardPlugin\Model\GiftCardInterface", mappedBy="orderItemUnit", cascade={"all"}) */
protected ?GiftCardInterface $giftCard = null;

public function getGiftCard(): ?GiftCardInterface
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/api_resources/Order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<attribute name="method">PATCH</attribute>
<attribute name="path">/shop/orders/{tokenValue}/address</attribute>
<attribute name="messenger">input</attribute>
<attribute name="input">Sylius\Bundle\ApiBundle\Command\Checkout\AddressOrder</attribute>
<attribute name="input">Sylius\Bundle\ApiBundle\Command\Checkout\UpdateCart</attribute>
<attribute name="denormalization_context">
<attribute name="groups">shop:cart:address</attribute>
</attribute>
Expand Down Expand Up @@ -330,7 +330,7 @@
<attribute name="method">PATCH</attribute>
<attribute name="path">/shop/orders/{tokenValue}/apply-coupon</attribute>
<attribute name="messenger">input</attribute>
<attribute name="input">Sylius\Bundle\ApiBundle\Command\Cart\ApplyCouponToCart</attribute>
<attribute name="input">Sylius\Bundle\ApiBundle\Command\Checkout\UpdateCart</attribute>
<attribute name="denormalization_context">
<attribute name="groups">shop:cart:apply_coupon</attribute>
</attribute>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/doctrine/model/GiftCard.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<!-- Refers to the order item unit where this gift card was bought -->
<one-to-one field="orderItemUnit" target-entity="Sylius\Component\Order\Model\OrderItemUnitInterface"
inversed-by="giftCard">
<cascade>
<cascade-all/>
</cascade>
<join-column name="order_item_unit_id" referenced-column-name="id" on-delete="CASCADE"/>
</one-to-one>

Expand Down
2 changes: 1 addition & 1 deletion tests/Application/.env
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ JWT_PASSPHRASE=setono_sylius_gift_card_plugin_development
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost
MAILER_DSN=null://localhost
###< symfony/swiftmailer-bundle ###
13 changes: 7 additions & 6 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Symfony\Component\HttpKernel\Config\FileLocator;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\RouteCollectionBuilder;
use Webmozart\Assert\Assert;

Expand Down Expand Up @@ -64,25 +65,25 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
}

protected function configureRoutes(RouteCollectionBuilder $routes): void
protected function configureRoutes(RoutingConfigurator $routes): void
{
$confDir = $this->getProjectDir() . '/config';

$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, 'glob');
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS,'glob');
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, 'glob');
}

protected function getContainerBaseClass(): string
{
if ($this->isTestEnvironment()) {
if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) {
return MockerContainer::class;
}

return parent::getContainerBaseClass();
}

protected function getContainerLoader(ContainerInterface $container): LoaderInterface
protected function getContainerLoader(ContainerInterface $container): DelegatingLoader
{
/** @var ContainerBuilder $container */
Assert::isInstanceOf($container, ContainerBuilder::class);
Expand Down
19 changes: 0 additions & 19 deletions tests/Application/Model/ChannelPricing.php

This file was deleted.

2 changes: 0 additions & 2 deletions tests/Application/Model/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Tests\Setono\SyliusGiftCardPlugin\Application\Model;

use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusGiftCardPlugin\Model\OrderItemTrait;
use Setono\SyliusGiftCardPlugin\Model\ProductInterface;
use Sylius\Component\Core\Model\OrderItem as BaseOrderItem;

Expand All @@ -17,5 +16,4 @@
*/
class OrderItem extends BaseOrderItem
{
use OrderItemTrait;
}
14 changes: 0 additions & 14 deletions tests/Application/Repository/ChannelPricingRepository.php

This file was deleted.

14 changes: 0 additions & 14 deletions tests/Application/Repository/ProductRepository.php

This file was deleted.

14 changes: 0 additions & 14 deletions tests/Application/Repository/ProductVariantRepository.php

This file was deleted.

5 changes: 2 additions & 3 deletions tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true],
Expand Down Expand Up @@ -34,8 +33,6 @@
Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true],
// End: In test app, those 3 needs to be loaded before our plugin or the Api Resource override won't work
Setono\SyliusGiftCardPlugin\SetonoSyliusGiftCardPlugin::class => ['all' => true],
Setono\JobStatusBundle\SetonoJobStatusBundle::class => ['all' => true],
Setono\SyliusCatalogPromotionPlugin\SetonoSyliusCatalogPromotionPlugin::class => ['all' => true],
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true],
Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
Expand All @@ -61,4 +58,6 @@
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true],
];
9 changes: 0 additions & 9 deletions tests/Application/config/packages/_sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ sylius_shop:
product_grid:
include_all_descendants: true

sylius_core:
resources:
channel_pricing:
classes:
model: Tests\Setono\SyliusGiftCardPlugin\Application\Model\ChannelPricing
repository: Tests\Setono\SyliusGiftCardPlugin\Application\Repository\ChannelPricingRepository

sylius_customer:
resources:
customer:
Expand All @@ -42,8 +35,6 @@ sylius_product:
product:
classes:
model: Tests\Setono\SyliusGiftCardPlugin\Application\Model\Product
repository: Tests\Setono\SyliusGiftCardPlugin\Application\Repository\ProductRepository
product_variant:
classes:
repository: Tests\Setono\SyliusGiftCardPlugin\Application\Repository\ProductVariantRepository

3 changes: 3 additions & 0 deletions tests/Application/config/packages/mailer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
Loading
Loading