Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/4.1' into tao-s
Browse files Browse the repository at this point in the history
  • Loading branch information
carkn committed Nov 29, 2021
2 parents 7581133 + 530906d commit 1c19503
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 29 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ jobs:
- name: composer install
run: composer install --dev --no-interaction -o --apcu-autoloader

- name: Setup pcov
run: |
sudo apt-fast install -y php7.4-pcov
sudo phpenmod -s cli pcov
composer require pcov/clobber --dev
vendor/bin/pcov clobber
- name: Setup EC-CUBE
env:
DATABASE_URL: ${{ matrix.database_url }}
Expand All @@ -76,9 +83,7 @@ jobs:
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
MAILER_URL: 'smtp://127.0.0.1:1025'
continue-on-error: true
run: |
bin/phpunit --version
phpdbg -dmemory_limit=-1 -qrr bin/phpunit --exclude-group cache-clear,cache-clear-install,update-schema-doctrine --coverage-clover=coverage1.xml
run: bin/phpunit --exclude-group cache-clear,cache-clear-install,update-schema-doctrine --coverage-clover=coverage1.xml
- name: Upload report
if: success()
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -204,6 +209,7 @@ jobs:
GROUP: ${{ matrix.group }}
SYMFONY_DEPRECATIONS_HELPER: weak
XDEBUG_MODE: coverage
continue-on-error: true
run: vendor/bin/codecept -vvv run acceptance --env chrome,github_action -g ${GROUP} --skip-group excludeCoverage --coverage --coverage-xml
- name: Upload outputs
uses: actions/upload-artifact@v2
Expand Down
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ FROM php:7.4-apache-bullseye

ENV APACHE_DOCUMENT_ROOT /var/www/html

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
RUN apt update \
&& apt upgrade -y \
&& apt install --no-install-recommends -y \
apt-transport-https \
apt-utils \
build-essential \
Expand All @@ -24,8 +25,8 @@ RUN apt-get update \
unzip \
zlib1g-dev \
libwebp-dev \
&& apt-get upgrade -y ca-certificates \
&& apt-get clean \
&& apt upgrade -y ca-certificates \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* \
&& echo "en_US.UTF-8 UTF-8" >/etc/locale.gen \
&& locale-gen \
Expand All @@ -39,8 +40,9 @@ RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
RUN pecl install apcu && echo "extension=apcu.so" > /usr/local/etc/php/conf.d/apc.ini

RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& apt update \
&& apt install -y nodejs \
&& apt clean \
;

RUN mkdir -p ${APACHE_DOCUMENT_ROOT} \
Expand Down
3 changes: 2 additions & 1 deletion codeception/acceptance/EA04OrderCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public function order_受注検索(AcceptanceTester $I)
OrderManagePage::go($I)->検索();
$I->see('検索結果:'.count($TargetOrders).'件が該当しました', OrderManagePage::$検索結果_メッセージ);

OrderManagePage::go($I)->検索($TargetOrders[0]->getName01());
$TargetOrder = array_values($TargetOrders)[0];
OrderManagePage::go($I)->検索($TargetOrder->getName01());
$I->dontSee('検索結果:0件が該当しました', OrderManagePage::$検索結果_メッセージ);

OrderManagePage::go($I)->検索('[email protected]');
Expand Down
3 changes: 2 additions & 1 deletion src/Eccube/Command/InstallerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$databaseUrl = 'sqlite:///var/eccube.db';
}
$this->envFileUpdater->databaseUrl = $this->io->ask('Database Url', $databaseUrl);
$databaseUrl = $this->envFileUpdater->databaseUrl;

// DATABASE_SERVER_VERSION
$this->envFileUpdater->serverVersion = $this->getDatabaseServerVersion($databaseUrl);
Expand Down Expand Up @@ -252,7 +253,7 @@ protected function getDatabaseName($databaseUrl)
if (0 === strpos($databaseUrl, 'sqlite')) {
return 'sqlite';
}
if (0 === strpos($databaseUrl, 'postgres')) {
if (0 === strpos($databaseUrl, 'postgres') || 0 === strpos($databaseUrl, 'pgsql')) {
return 'postgres';
}
if (0 === strpos($databaseUrl, 'mysql')) {
Expand Down
5 changes: 3 additions & 2 deletions src/Eccube/Command/PluginGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,15 @@ protected function createDirectories($pluginDir)
*/
protected function createConfig($pluginDir, $name, $code, $version)
{
$lowerCode = mb_strtolower($code);
$source = <<<EOL
{
"name": "ec-cube/$code",
"name": "ec-cube/$lowerCode",
"version": "$version",
"description": "$name",
"type": "eccube-plugin",
"require": {
"ec-cube/plugin-installer": "~0.0.7"
"ec-cube/plugin-installer": "~0.0.7 || ^2.0"
},
"extra": {
"code": "$code"
Expand Down
15 changes: 14 additions & 1 deletion src/Eccube/Controller/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

namespace Eccube\Controller;

use Eccube\Entity\BaseInfo;
use Eccube\Entity\Page;
use Eccube\Repository\BaseInfoRepository;
use Eccube\Repository\CategoryRepository;
use Eccube\Repository\Master\ProductListOrderByRepository;
use Eccube\Repository\PageRepository;
Expand Down Expand Up @@ -53,6 +55,11 @@ class SitemapController extends AbstractController
*/
private $router;

/**
* @var BaseInfo
*/
protected $BaseInfo;

/**
* SitemapController constructor.
*/
Expand All @@ -61,13 +68,15 @@ public function __construct(
PageRepository $pageRepository,
ProductListOrderByRepository $productListOrderByRepository,
ProductRepository $productRepository,
RouterInterface $router
RouterInterface $router,
BaseInfoRepository $baseInfoRepository
) {
$this->categoryRepository = $categoryRepository;
$this->pageRepository = $pageRepository;
$this->productListOrderByRepository = $productListOrderByRepository;
$this->productRepository = $productRepository;
$this->router = $router;
$this->BaseInfo = $baseInfoRepository->get();
}

/**
Expand Down Expand Up @@ -136,6 +145,10 @@ public function category()
*/
public function product(Request $request, PaginatorInterface $paginator)
{
// Doctrine SQLFilter
if ($this->BaseInfo->isOptionNostockHidden()) {
$this->entityManager->getFilters()->enable('option_nostock_hidden');
}
// フロントの商品一覧の条件で商品情報を取得
$ProductListOrder = $this->productListOrderByRepository->find($this->eccubeConfig['eccube_product_order_newer']);
$productQueryBuilder = $this->productRepository->getQueryBuilderBySearchData(['orderby' => $ProductListOrder]);
Expand Down
4 changes: 2 additions & 2 deletions src/Eccube/Entity/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ public function getDeliveryFeeTotal()
}

/**
* @return Customer
* @return Customer|null
*/
public function getCustomer(): Customer
public function getCustomer(): ?Customer
{
return $this->Customer;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Eccube/Entity/CartItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ public function getCart()
public function setCart(Cart $Cart)
{
$this->Cart = $Cart;

return $this;
}
}
}
4 changes: 2 additions & 2 deletions src/Eccube/Form/Type/Admin/ShopMasterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'required' => false,
'constraints' => [
new Assert\Length([
'max' => $this->eccubeConfig['eccube_lltext_len'],
'max' => $this->eccubeConfig['eccube_ltext_len'],
]),
],
])
->add('message', TextareaType::class, [
'required' => false,
'constraints' => [
new Assert\Length([
'max' => $this->eccubeConfig['eccube_lltext_len'],
'max' => $this->eccubeConfig['eccube_ltext_len'],
]),
],
])
Expand Down
1 change: 1 addition & 0 deletions src/Eccube/Resource/locale/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ front.shopping.out_of_stock_zero: 'Sorry, we do not have enough stock for %produ
front.shopping.over_price_limit: Sorry, the quantity exceeds the max. purchase amount. Please reduce the purchase quantity.
front.shopping.in_preparation: 'Sorry, %product% is not ready for shipment. Please contact us from the inquiry form. We are sorry for the inconvenience.'
front.shopping.not_purchase: Sorry, your order includes item(s) currently unavailable. It has been deleted from your cart.
front.shopping.not_purchase_product_class: 'Sorry, %product% is currently unavailable. It has been deleted from your cart.'
front.shopping.price_changed: 'The selling price of %product% has been changed.'
front.shopping.payment_total_invalid: The total amount is invalid.
front.shopping.different_payment_methods: Sorry, your order includes items with different purchase methods, which are unable to be processed in one order.
Expand Down
1 change: 1 addition & 0 deletions src/Eccube/Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ front.shopping.out_of_stock_zero: '「%product%」の在庫が不足しており
front.shopping.over_price_limit: 商品を購入できる金額の上限を超えております。数量を調整してください。
front.shopping.in_preparation: '「%product%」はまだ配送の準備ができておりません。恐れ入りますがお問い合わせページよりお問い合わせください。'
front.shopping.not_purchase: 現時点で購入できない商品が含まれておりました。該当商品をカートから削除しました。
front.shopping.not_purchase_product_class: '「%product%」は現時点で購入できません。該当商品をカートから削除しました。'
front.shopping.price_changed: '「%product%」の販売価格が変更されました。'
front.shopping.payment_total_invalid: 合計金額が不正です。
front.shopping.different_payment_methods: 支払い方法が異なる商品が含まれているため、同時に購入することはできません。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ class ProductStatusValidator extends ItemValidator
protected function validate(ItemInterface $item, PurchaseContext $context)
{
if ($item->isProduct()) {
$Product = $item->getProductClass()->getProduct();
$ProductClass = $item->getProductClass();
if (!$item->getProductClass()->isVisible()) {
$this->throwInvalidItemException('front.shopping.not_purchase_product_class', $ProductClass);
}

$Product = $ProductClass->getProduct();
if ($Product->getStatus()->getId() != ProductStatus::DISPLAY_SHOW) {
$this->throwInvalidItemException('front.shopping.not_purchase');
}
Expand Down
12 changes: 12 additions & 0 deletions tests/Eccube/Tests/Form/Type/Admin/ShopMasterTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,16 @@ public function testInValidBasicPointRateRangeMax()
$this->form->submit($this->formData);
$this->assertFalse($this->form->isValid());
}
public function testInValidGoodTradedMaxLength()
{
$this->formData['good_traded'] = str_repeat('1', $this->eccubeConfig['eccube_ltext_len'] + 1);
$this->form->submit($this->formData);
$this->assertFalse($this->form->isValid());
}
public function testInValidMessageMaxLength()
{
$this->formData['message'] = str_repeat('1', $this->eccubeConfig['eccube_ltext_len'] + 1);
$this->form->submit($this->formData);
$this->assertFalse($this->form->isValid());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ protected function createFavorites($Customer)
*/
protected function setProductTags(Product $Product, array $tagIds)
{
$ProductTags = $Product->getProductTag();
foreach ($ProductTags as $ProductTag) {
$Product->removeProductTag($ProductTag);
$this->entityManager->remove($ProductTag);
}

$Tags = $this->tagRepository->findBy(['id' => $tagIds]);
foreach ($Tags as $Tag) {
$ProductTag = new ProductTag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ public function testTagSearch()
$Products[0]->setName('りんご');
$this->setProductTags($Products[0], [1]);
$this->setProductTags($Products[1], [1, 2]);
$this->setProductTags($Products[2], []);
$this->entityManager->flush();

// タグ 1 で検索
Expand Down
10 changes: 5 additions & 5 deletions tests/Eccube/Tests/Service/CartServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function setUp()

public function testClear()
{
$this->cartService->addProduct(1);
$this->cartService->addProduct(2);
$this->purchaseFlow->validate($this->cartService->getCart(), new PurchaseContext());
$this->cartService->save();

Expand Down Expand Up @@ -172,7 +172,7 @@ public function testAddProductsWithCartItemComparator()
// 同じ商品規格で同じ数量なら同じ明細とみなすようにする
$this->cartService->setCartItemComparator(new CartServiceTest_CartItemComparator());

$ProductClass = $this->productClassRepository->find(1);
$ProductClass = $this->productClassRepository->find(2);

$this->cartService->addProduct($ProductClass, 1);
$this->purchaseFlow->validate($this->cartService->getCart(), new PurchaseContext());
Expand All @@ -185,7 +185,7 @@ public function testAddProductsWithCartItemComparator()
/* @var \Eccube\Entity\CartItem[] $CartItems */
$CartItems = $this->cartService->getCart()->getCartItems();
self::assertEquals(1, count($CartItems));
self::assertEquals(1, $CartItems[0]->getProductClassId());
self::assertEquals(2, $CartItems[0]->getProductClassId());
self::assertEquals(2, $CartItems[0]->getQuantity());

$this->cartService->addProduct($ProductClass, 1);
Expand All @@ -195,9 +195,9 @@ public function testAddProductsWithCartItemComparator()
/* @var \Eccube\Entity\CartItem[] $CartItems */
$CartItems = $this->cartService->getCart()->getCartItems();
self::assertEquals(2, count($CartItems));
self::assertEquals(1, $CartItems[0]->getProductClassId());
self::assertEquals(2, $CartItems[0]->getProductClassId());
self::assertEquals(2, $CartItems[0]->getQuantity());
self::assertEquals(1, $CartItems[1]->getProductClassId());
self::assertEquals(2, $CartItems[1]->getProductClassId());
self::assertEquals(1, $CartItems[1]->getQuantity());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,17 @@ public function testDisplayStatusWithClosed()

self::assertEquals(0, $this->cartItem->getQuantity());
}


/**
* 無効になっている商品規格の場合は明細の個数を0に設定する.
*/
public function testProductClassVisibleFalse()
{
$this->ProductClass->setVisible(false);

$this->validator->execute($this->cartItem, new PurchaseContext());

self::assertEquals(0, $this->cartItem->getQuantity());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function createShippingFormData()
return $form;
}

protected function scenarioCartIn(Customer $Customer = null, $product_class_id = 1)
protected function scenarioCartIn(Customer $Customer = null, $product_class_id = 2)
{
if ($Customer) {
$this->loginTo($Customer);
Expand Down
4 changes: 2 additions & 2 deletions tests/Eccube/Tests/Web/ShoppingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ public function testPaymentLimitAndPointCombination()
$price = 27777;
$pointUse = 27777;
/** @var ProductClass $ProductClass */
$ProductClass = $this->entityManager->getRepository(\Eccube\Entity\ProductClass::class)->find(1);
$ProductClass = $this->entityManager->getRepository(\Eccube\Entity\ProductClass::class)->find(2);
$ProductClass->setPrice02($price);
$this->entityManager->flush($ProductClass);

Expand All @@ -660,7 +660,7 @@ public function testPaymentLimitAndPointCombination()
$COD2 = self::$container->get(Generator::class)->createPayment($Delivery, 'COD2', 0, 30001, 300000);

// カート画面
$this->scenarioCartIn($Customer, 1);
$this->scenarioCartIn($Customer, 2);

// 確認画面
$this->scenarioConfirm($Customer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ public function testAddMultiShippingWithOneAddressOneItem()
*/
public function testAddMultiShippingWithOneAddressOneItemTwoQuantities()
{
$this->scenarioCartIn(null, 1);
$this->scenarioCartIn(null, 1);
$this->scenarioCartIn(null, 2);
$this->scenarioCartIn(null, 2);

$formData = $this->createNonmemberFormData();
$this->scenarioInput($formData);
Expand Down

0 comments on commit 1c19503

Please sign in to comment.