Skip to content

Commit

Permalink
Merge pull request #72 from nanasess/improve/4.1
Browse files Browse the repository at this point in the history
4.1 support
  • Loading branch information
Kiyotaka Oku authored Aug 12, 2021
2 parents 26d9f40 + 6fdc3bf commit 9007d9a
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 24 deletions.
179 changes: 179 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: CI for ProductReview4
on:
push:
branches:
- '*'
tags:
- '*'
paths:
- '**'
- '!*.md'
pull_request:
branches:
- '*'
paths:
- '**'
- '!*.md'
jobs:
run-on-linux:
name: Run on Linux
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-18.04 ]
php: [ '7.1', '7.2', '7.3', '7.4' ]
db: [ mysql, pgsql ]
eccube_version: [ '4.0.6-p1', '4.1' ]
plugin_code: [ 'ProductReview4' ]
include:
- eccube_version: '4.0.6-p1'
composer: 'v1'
- eccube_version: '4.1'
composer: 'v2'
- db: mysql
dbport: '3306'
dbuser: 'root'
dbpass: 'root'
dbname: 'myapp_test'
dbversion: 5.7
- db: pgsql
dbport: '5432'
dbuser: 'postgres'
dbpass: 'password'
dbname: 'myapp_test'
dbversion: 9.5
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ${{ matrix.dbname }}
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:9.5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: ${{ matrix.dbname }}
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mailcatcher:
image: schickling/mailcatcher
ports:
- 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
with:
php-version: ${{ matrix.php }}

- name: Archive Plugin
env:
PLUGIN_CODE: ${{ matrix.plugin_code }}
run: |
tar cvzf ${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz ./*
- name: Checkout EC-CUBE
uses: actions/checkout@v2
with:
repository: 'EC-CUBE/ec-cube'
ref: ${{ matrix.eccube_version }}
path: 'ec-cube'

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- if: matrix.composer == 'v1'
run: sudo composer selfupdate --1

- name: Install to composer
working-directory: 'ec-cube'
run: composer install --no-interaction -o --apcu-autoloader

- if: matrix.composer == 'v1'
working-directory: 'ec-cube'
run: composer require kiy0taka/eccube4-test-fixer "dev-main@dev"

- name: Setup EC-CUBE
env:
DB: ${{ matrix.db }}
USER: ${{ matrix.dbuser }}
DBUSER: ${{ matrix.dbuser }}
DBPASS: ${{ matrix.dbpass }}
DBNAME: ${{ matrix.dbname }}
DBPORT: ${{ matrix.dbport }}
DBSERVER: 127.0.0.1
DBVERSION: ${{ matrix.dbversion }}
ROOT_URLPATH: /ec-cube/html
working-directory: 'ec-cube'
run: |
export PGPASSWORD=${DBPASS}
echo "APP_ENV=prod" > .env
echo "APP_DEBUG=0" >> .env
echo "DATABASE_URL=${DB}://${DBUSER}:${DBPASS}@${DBSERVER}/${DBNAME}" >> .env
echo "DATABASE_SERVER_VERSION=${DBVERSION}" >> .env
echo "MAILER_URL=smtp://127.0.0.1:1025" >> .env
echo "HTTP_SITEURL=https://localhost" >> .env
echo "USE_SELFSIGNED_SSL_CERTIFICATE=1" >> .env
cat .env
bin/console doctrine:schema:create
bin/console eccube:fixtures:load
- name: Setup Plugin
env:
PLUGIN_CODE: ${{ matrix.plugin_code }}
working-directory: 'ec-cube'
run: |
bin/console eccube:plugin:install --code=${PLUGIN_CODE} --path=${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz
bin/console cache:clear --no-warmup
bin/console cache:warmup
bin/console eccube:plugin:enable --code=${PLUGIN_CODE}
rm codeception/_support/*Tester.php
- name: Run PHPUnit
if: matrix.composer == 'v2'
env:
PLUGIN_CODE: ${{ matrix.plugin_code }}
working-directory: 'ec-cube'
run: bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests

- name: Run PHPUnit
if: matrix.composer == 'v1'
env:
PLUGIN_CODE: ${{ matrix.plugin_code }}
working-directory: 'ec-cube'
run: |
find app/Plugin/${PLUGIN_CODE}/Tests -name "*Test.php" | while read TESTCASE
do
./vendor/bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist --include-path vendor/kiy0taka/eccube4-test-fixer/src --loader 'Eccube\PHPUnit\Loader\Eccube4CompatTestSuiteLoader' ${TESTCASE}
done
- name: Disable Plugin
working-directory: 'ec-cube'
env:
PLUGIN_CODE: ${{ matrix.plugin_code }}
run: bin/console eccube:plugin:disable --code=${PLUGIN_CODE}

- name: Uninstall Plugin
env:
PLUGIN_CODE: ${{ matrix.plugin_code }}
working-directory: 'ec-cube'
run: bin/console eccube:plugin:uninstall --code=${PLUGIN_CODE}
19 changes: 16 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ env:
- ECCUBE_VERSION=4.0.2 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9
- ECCUBE_VERSION=4.0.3 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5
- ECCUBE_VERSION=4.0.3 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9
- ECCUBE_VERSION=4.1 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5
- ECCUBE_VERSION=4.1 DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9
matrix:
exclude:
- php: 7.3
Expand Down Expand Up @@ -80,10 +82,12 @@ setup_composer: &setup_composer |
cd -

install_eccube: &install_eccube |
sh -c "if [ ! '${ECCUBE_VERSION}' = '4.1' ]; then composer selfupdate --1; fi"
sh -c "if [ '${ECCUBE_VERSION}' = '4.1' ]; then composer selfupdate; fi"
tar cvzf ${HOME}/${PLUGIN_CODE}.tar.gz ./*
git clone https://github.com/EC-CUBE/ec-cube.git
cd ec-cube
sh -c "if [ '${ECCUBE_VERSION}' = '4.0' ]; then git checkout origin/${ECCUBE_VERSION}; fi"
sh -c "if [ '${ECCUBE_VERSION}' = '4.0' ] || [ '${ECCUBE_VERSION}' = '4.1' ]; then git checkout origin/${ECCUBE_VERSION}; fi"
sh -c "if [ ! '${ECCUBE_VERSION}' = '4.0' ]; then git checkout refs/tags/${ECCUBE_VERSION}; fi"
composer install --dev --no-interaction -o --apcu-autoloader

Expand All @@ -99,9 +103,18 @@ install:
- *setup_composer
- *install_eccube
- *eccube_setup
- composer require --dev kiy0taka/eccube4-test-fixer

script:
- ./vendor/bin/phpunit app/Plugin/${PLUGIN_CODE}/Tests;
script: |
if [[ ! $ECCUBE_VERSION = '4.1' ]]
then
find app/Plugin/${PLUGIN_CODE}/Tests -name "*Test.php" | while read TESTCASE
do
./vendor/bin/phpunit --include-path vendor/kiy0taka/eccube4-test-fixer/src --loader 'Eccube\PHPUnit\Loader\Eccube4CompatTestSuiteLoader' ${TESTCASE}
done
else
./vendor/bin/phpunit app/Plugin/${PLUGIN_CODE}/Tests
fi
after_script:
# disable plugin
Expand Down
6 changes: 3 additions & 3 deletions PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PluginManager extends AbstractPluginManager

public function enable(array $meta, ContainerInterface $container)
{
$em = $container->get('doctrine.orm.entity_manager');
$em = $container->get('doctrine')->getManager();

// プラグイン設定を追加
$Config = $this->createConfig($em);
Expand All @@ -74,7 +74,7 @@ public function enable(array $meta, ContainerInterface $container)

// ページを追加
foreach ($this->pages as $pageInfo) {
$Page = $container->get(PageRepository::class)->findOneBy(['url' => $pageInfo['url']]);
$Page = $em->getRepository(Page::class)->findOneBy(['url' => $pageInfo['url']]);
if (null === $Page) {
$this->createPage($em, $pageInfo['name'], $pageInfo['url'], $pageInfo['filename']);
}
Expand All @@ -95,7 +95,7 @@ public function disable(array $meta, ContainerInterface $container)

public function uninstall(array $meta, ContainerInterface $container)
{
$em = $container->get('doctrine.orm.entity_manager');
$em = $container->get('doctrine')->getManager();

// ページを削除
foreach ($this->pages as $pageInfo) {
Expand Down
12 changes: 4 additions & 8 deletions Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ product_review.common.required: 必須
product_review.admin.config.title: レビュー設定
product_review.admin.config.sub_title: プラグイン一覧
product_review.admin.config.config_title: 設定
product_review.admin.config.review_max: レビューの表示件数(%min%〜%max%)
product_review.admin.config.review_max: 'レビューの表示件数(%min%〜%max%)'
product_review.admin.config.conversion.save: 登録
product_review.admin.config.conversion.back: プラグイン一覧

Expand All @@ -22,7 +22,7 @@ product_review.admin.product_review.sub_title: 商品管理
product_review.admin.product_review.search_detail: 詳細検索
product_review.admin.product_review.search_button: 検索
product_review.admin.product_review.search_clear: 検索条件をクリア
product_review.admin.product_review.search_result_count: 検索結果:%count%件が該当しました。
product_review.admin.product_review.search_result_count: '検索結果:%count%件が該当しました。'
product_review.admin.product_review.search_multi: 投稿者名・投稿者URL
product_review.admin.product_review.search_product_name: 商品名
product_review.admin.product_review.search_product_code: 商品コード
Expand All @@ -36,7 +36,7 @@ product_review.admin.product_review.search_no_result: 検索条件に合致す
product_review.admin.product_review.search_invalid_condition: 検索条件に誤りがあります
product_review.admin.product_review.search_change_condition_and_retry: 検索条件を変えて、再度検索をお試しください。
product_review.admin.product_review.search_try_detail_condition: '[詳細検索]も試してみましょう。'
product_review.admin.product_review.diaply_count: %count%件
product_review.admin.product_review.diaply_count: '%count%件'
product_review.admin.product_review.csv_download: CSVダウンロード
product_review.admin.product_review.csv_download_setting: CSV出力項目設定
product_review.admin.product_review.th_posted_date: 投稿日
Expand Down Expand Up @@ -90,8 +90,4 @@ product_review.form.product_review.recommend_level: おすすめレベル
product_review.front.product_detail.title: この商品のレビュー
product_review.front.product_detail.no_review: レビューはありません。
product_review.front.product_detail.post_review: レビューを投稿
product_review.front.product_detail.name: %name% さん




product_review.front.product_detail.name: '%name% さん'
2 changes: 1 addition & 1 deletion Tests/Web/ProductReviewConfigControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function testMin()
$form['product_review_config[review_max]'] = $this->faker->numberBetween(-10, $min - 1);
$crawler = $client->submit($form);

$this->assertContains($min.'以上でなければなりません。', $crawler->html());
$this->assertContains($min.'以上', $crawler->html());
}

/**
Expand Down
8 changes: 5 additions & 3 deletions Tests/Web/ReviewAdminControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Plugin\ProductReview4\Tests\Web;

use Eccube\Entity\Master\Sex;
use Eccube\Entity\Product;
use Eccube\Repository\Master\ProductStatusRepository;
use Eccube\Repository\Master\SexRepository;
Expand All @@ -25,6 +26,7 @@
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\HttpFoundation\Response;


/**
* Class ReviewAdminControllerTest.
*/
Expand Down Expand Up @@ -59,9 +61,9 @@ public function setUp()
$this->faker = $this->getFaker();
$this->deleteAllRows(['plg_product_review']);

$this->productRepo = $this->container->get(ProductRepository::class);
$this->sexMasterRepo = $this->container->get(SexRepository::class);
$this->productReviewRepo = $this->container->get(ProductReviewRepository::class);
$this->productRepo = $this->entityManager->getRepository(Product::class);
$this->sexMasterRepo = $this->entityManager->getRepository(Sex::class);
$this->productReviewRepo = $this->entityManager->getRepository(ProductReview::class);
}

/**
Expand Down
8 changes: 5 additions & 3 deletions Tests/Web/ReviewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Plugin\ProductReview4\Tests\Web;

use Eccube\Entity\Master\Sex;
use Eccube\Entity\Product;
use Eccube\Repository\Master\ProductStatusRepository;
use Eccube\Repository\Master\SexRepository;
Expand All @@ -24,6 +25,7 @@
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;


/**
* Class ReviewControllerTest front.
*/
Expand Down Expand Up @@ -58,9 +60,9 @@ public function setUp()
$this->faker = $this->getFaker();
$this->deleteAllRows(['plg_product_review']);

$this->productRepo = $this->container->get(ProductRepository::class);
$this->sexMasterRepo = $this->container->get(SexRepository::class);
$this->productStatusRepo = $this->container->get(ProductStatusRepository::class);
$this->productRepo = $this->entityManager->getRepository(Product::class);
$this->sexMasterRepo = $this->entityManager->getRepository(Sex::class);
$this->productReviewRepo = $this->entityManager->getRepository(ProductReview::class);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "ec-cube/ProductReview4",
"version": "4.0.2",
"name": "ec-cube/productreview4",
"version": "4.1.0",
"description": "商品レビュー管理プラグイン",
"type": "eccube-plugin",
"require": {
"ec-cube/plugin-installer": "~0.0.6"
"ec-cube/plugin-installer": "~0.0.6 || ^2.0"
},
"extra": {
"code": "ProductReview4"
Expand Down

0 comments on commit 9007d9a

Please sign in to comment.