Skip to content

Commit

Permalink
Merge pull request #193 from ptthao-yrglmvn/migration-4.3
Browse files Browse the repository at this point in the history
Compatible 4.3
  • Loading branch information
chihiro-adachi authored Apr 8, 2024
2 parents fec06cb + 92495d4 commit 45f399b
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 80 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ on:
jobs:
run-on-linux:
name: Run on Linux
runs-on: ${{ matrix.operating-system }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-18.04 ]
php: [ '7.4', '8.0', '8.1' ]
eccube_version: [ '4.2', '4.3' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3']
db: [ 'mysql', 'mysql8', 'pgsql' ]
eccube_version: [ '4.2' ]
plugin_code: [ 'Coupon42' ]
include:
- db: mysql
Expand All @@ -39,6 +38,15 @@ jobs:
database_url: postgres://postgres:[email protected]:5432/eccube_db
database_server_version: 14
database_charset: utf8
exclude:
- eccube_version: 4.2
php: 8.2
- eccube_version: 4.2
php: 8.3
- eccube_version: 4.3
php: 7.4
- eccube_version: 4.3
php: 8.0
services:
mysql:
image: mysql:5.7
Expand Down Expand Up @@ -72,15 +80,14 @@ jobs:
- 1080:1080
- 1025:1025
steps:
- run: sudo apt-get purge -y hhvm
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: nanasess/setup-php@master
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

extensions: :xdebug
- name: Archive Plugin
env:
PLUGIN_CODE: ${{ matrix.plugin_code }}
Expand Down Expand Up @@ -143,7 +150,7 @@ jobs:
working-directory: 'ec-cube'
run: |
bin/console cache:clear --no-warmup
bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests
./vendor/bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests
- name: Disable Plugin
working-directory: 'ec-cube'
Expand Down
6 changes: 3 additions & 3 deletions Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Event implements EventSubscriberInterface
private $orderRepository;

/**
* @var \Twig_Environment
* @var \Twig\Environment
*/
private $twig;

Expand All @@ -59,9 +59,9 @@ class Event implements EventSubscriberInterface
* @param EntityManagerInterface $entityManager
* @param CouponRepository $couponRepository
* @param OrderRepository $orderRepository
* @param \Twig_Environment $twig
* @param \Twig\Environment $twig
*/
public function __construct(CouponOrderRepository $couponOrderRepository, EntityManagerInterface $entityManager, CouponRepository $couponRepository, OrderRepository $orderRepository, \Twig_Environment $twig)
public function __construct(CouponOrderRepository $couponOrderRepository, EntityManagerInterface $entityManager, CouponRepository $couponRepository, OrderRepository $orderRepository, \Twig\Environment $twig)
{
$this->couponOrderRepository = $couponOrderRepository;
$this->entityManager = $entityManager;
Expand Down
10 changes: 5 additions & 5 deletions Form/Type/CouponType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Eccube\Form\Type\PriceType;
use Plugin\Coupon42\Entity\Coupon;
use Plugin\Coupon42\Repository\CouponRepository;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
Expand Down Expand Up @@ -50,7 +50,7 @@ class CouponType extends AbstractType
private $validator;

/**
* @var ContainerInterface
* @var ContainerBagInterface
*/
private $container;

Expand All @@ -59,9 +59,9 @@ class CouponType extends AbstractType
*
* @param CouponRepository $couponRepository
* @param ValidatorInterface $validator
* @param ContainerInterface $container
* @param ContainerBagInterface $container
*/
public function __construct(CouponRepository $couponRepository, ValidatorInterface $validator, ContainerInterface $container)
public function __construct(CouponRepository $couponRepository, ValidatorInterface $validator, ContainerBagInterface $container)
{
$this->couponRepository = $couponRepository;
$this->validator = $validator;
Expand All @@ -76,7 +76,7 @@ public function __construct(CouponRepository $couponRepository, ValidatorInterfa
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$currency = $this->container->getParameter('currency');
$currency = $this->container->get('currency');
$builder
->add('coupon_cd', TextType::class, [
'label' => 'plugin_coupon.admin.label.coupon_cd',
Expand Down
7 changes: 4 additions & 3 deletions PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
namespace Plugin\Coupon42;

use Doctrine\ORM\EntityManagerInterface;
use Eccube\Common\EccubeConfig;
use Eccube\Entity\Layout;
use Eccube\Entity\Page;
use Eccube\Entity\PageLayout;
use Eccube\Plugin\AbstractPluginManager;
use Eccube\Repository\LayoutRepository;
use Eccube\Repository\PageLayoutRepository;
use Eccube\Repository\PageRepository;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Psr\Container\ContainerInterface;
use Symfony\Component\Filesystem\Filesystem;

/**
Expand Down Expand Up @@ -139,7 +140,7 @@ private function removePageLayout(ContainerInterface $container)
*/
private function copyBlock(ContainerInterface $container)
{
$templateDir = $container->getParameter('eccube_theme_front_dir');
$templateDir = $container->get(EccubeConfig::class)->get('eccube_theme_front_dir');
// ファイルコピー
$file = new Filesystem();
// ブロックファイルをコピー
Expand All @@ -155,7 +156,7 @@ private function copyBlock(ContainerInterface $container)
*/
private function removeBlock(ContainerInterface $container)
{
$templateDir = $container->getParameter('eccube_theme_front_dir');
$templateDir = $container->get(EccubeConfig::class)->get('eccube_theme_front_dir');
$file = new Filesystem();
$file->remove($templateDir.'/Coupon42/'.$this->template1);
$file->remove($templateDir.'/Coupon42/'.$this->template2);
Expand Down
4 changes: 2 additions & 2 deletions Resource/template/admin/regist_category_list_prototype.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% filter escape %}
{% apply escape %}
<div class="row item_box">
<input type="hidden" id="coupon_CouponDetails___name___id" name="coupon[CouponDetails][__name__][id]">
<input type="hidden" id="coupon_CouponDetails___name___Category" name="coupon[CouponDetails][__name__][Category]">
Expand All @@ -18,4 +18,4 @@
</a>
</div>
</div><!-- /.item_box -->
{% endfilter %}
{% endapply %}
4 changes: 2 additions & 2 deletions Resource/template/admin/regist_product_list_prototype.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% filter escape %}
{% apply escape %}
<div class="row item_box">
<div id="coupon_CouponDetails___name__" style="display: none">
<input type="hidden" id="coupon_CouponDetails___name___Product" name="coupon[CouponDetails][__name__][Product]" class="form-control" />
Expand All @@ -19,4 +19,4 @@
</a>
</div>
</div><!-- /.item_box -->
{% endfilter %}
{% endapply %}
8 changes: 4 additions & 4 deletions Service/CouponService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use Plugin\Coupon42\Repository\CouponOrderRepository;
use Plugin\Coupon42\Repository\CouponRepository;
use Plugin\Coupon42\Service\PurchaseFlow\Processor\CouponProcessor;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

/**
Expand Down Expand Up @@ -90,7 +90,7 @@ class CouponService
private $orderItemTypeRepository;

/**
* @var ContainerInterface
* @var ContainerBagInterface
*/
private $container;

Expand Down Expand Up @@ -121,7 +121,7 @@ class CouponService
* @param TaxTypeRepository $taxTypeRepository
* @param TaxDisplayTypeRepository $taxDisplayTypeRepository
* @param OrderItemTypeRepository $orderItemTypeRepository
* @param ContainerInterface $container
* @param ContainerBagInterface $container
* @param EntityManagerInterface $entityManager
* @param OrderItemRepository $orderItemRepository
* @param ProductClassRepository $productClassRepository
Expand All @@ -137,7 +137,7 @@ public function __construct(
TaxTypeRepository $taxTypeRepository,
TaxDisplayTypeRepository $taxDisplayTypeRepository,
OrderItemTypeRepository $orderItemTypeRepository,
ContainerInterface $container,
ContainerBagInterface $container,
EntityManagerInterface $entityManager,
OrderItemRepository $orderItemRepository,
ProductClassRepository $productClassRepository
Expand Down
18 changes: 9 additions & 9 deletions Tests/Service/CouponServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public function setUp(): void
$this->couponRepository = $this->entityManager->getRepository(Coupon::class);
$this->couponOrderRepository = $this->entityManager->getRepository(CouponOrder::class);
$this->taxRuleRepository = $this->entityManager->getRepository(TaxRule::class);
$this->taxRuleService = self::$container->get(TaxRuleService::class);
$this->couponService = self::$container->get(CouponService::class);
$this->taxRuleService = self::getContainer()->get(TaxRuleService::class);
$this->couponService = self::getContainer()->get(CouponService::class);
$this->orderItemTypeRepository = $this->entityManager->getRepository(OrderItemType::class);
}

Expand Down Expand Up @@ -158,7 +158,7 @@ public function testExistsCouponProductNot()
public function testExistsCouponProductTypeCategory()
{
/** @var Generator $Generator */
$Generator = self::$container->get(Generator::class);
$Generator = self::getContainer()->get(Generator::class);
/** @var Coupon $Coupon */
$Coupon = $this->getCoupon(Coupon::CATEGORY);

Expand Down Expand Up @@ -192,7 +192,7 @@ public function testExistsCouponProductAll()
{
$orderItemVolume = 5;
/** @var Generator $Generator */
$Generator = self::$container->get(Generator::class);
$Generator = self::getContainer()->get(Generator::class);
/** @var Coupon $Coupon */
$Coupon = $this->getCoupon(Coupon::ALL);

Expand All @@ -218,7 +218,7 @@ public function testExistsCouponProductWithMultiple()
{
$orderItemVolume = 2;
/** @var Generator $Generator */
$Generator = self::$container->get(Generator::class);
$Generator = self::getContainer()->get(Generator::class);
/** @var Coupon $Coupon */
$Coupon = $this->getCoupon(Coupon::ALL);

Expand Down Expand Up @@ -266,9 +266,9 @@ public function testSaveCouponOrder()

$discount = 200;

self::$container->get('security.token_storage')->setToken(
self::getContainer()->get('security.token_storage')->setToken(
new UsernamePasswordToken(
$Customer, null, 'customer', $Customer->getRoles()
$Customer, 'customer', $Customer->getRoles()
)
);

Expand Down Expand Up @@ -603,9 +603,9 @@ public function testRemoveCouponOrder()
$OtherOrder = $this->createOrder($Customer);
$discount = 100;

self::$container->get('security.token_storage')->setToken(
self::getContainer()->get('security.token_storage')->setToken(
new UsernamePasswordToken(
$Customer, null, 'customer', $Customer->getRoles()
$Customer, 'customer', $Customer->getRoles()
)
);

Expand Down
4 changes: 2 additions & 2 deletions Tests/Service/PurchaseFlow/CouponProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public function setUp(): void
{
parent::setUp();

$couponService = self::$container->get(CouponService::class);
$couponService = self::getContainer()->get(CouponService::class);
$couponRepository = $this->entityManager->getRepository(Coupon::class);
$couponOrderRepository = $this->entityManager->getRepository(CouponOrder::class);
$taxRuleService = self::$container->get(TaxRuleService::class);
$taxRuleService = self::getContainer()->get(TaxRuleService::class);
$taxRuleRepository = $this->entityManager->getRepository(TaxRule::class);
$this->processor = new CouponProcessor($this->entityManager, $couponService, $couponRepository,
$couponOrderRepository, $taxRuleService, $taxRuleRepository);
Expand Down
Loading

0 comments on commit 45f399b

Please sign in to comment.