Skip to content

Commit 853afba

Browse files
author
Kiyotaka Oku
authored
Merge pull request #80 from nanasess/improve/4.1
4.1 support
2 parents 046a058 + 6d4f789 commit 853afba

File tree

9 files changed

+201
-236
lines changed

9 files changed

+201
-236
lines changed

.github/workflows/main.yml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: CI for RelatedProduct4
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
tags:
7+
- '*'
8+
paths:
9+
- '**'
10+
- '!*.md'
11+
pull_request:
12+
branches:
13+
- '*'
14+
paths:
15+
- '**'
16+
- '!*.md'
17+
jobs:
18+
run-on-linux:
19+
name: Run on Linux
20+
runs-on: ${{ matrix.operating-system }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
operating-system: [ ubuntu-18.04 ]
25+
php: [ '7.1', '7.2', '7.3', '7.4' ]
26+
db: [ mysql, pgsql ]
27+
eccube_version: [ '4.0.6-p1', '4.1' ]
28+
plugin_code: [ 'RelatedProduct4' ]
29+
include:
30+
- eccube_version: '4.0.6-p1'
31+
composer: 'v1'
32+
- eccube_version: '4.1'
33+
composer: 'v2'
34+
- db: mysql
35+
dbport: '3306'
36+
dbuser: 'root'
37+
dbpass: 'root'
38+
dbname: 'myapp_test'
39+
dbversion: 5.7
40+
- db: pgsql
41+
dbport: '5432'
42+
dbuser: 'postgres'
43+
dbpass: 'password'
44+
dbname: 'myapp_test'
45+
dbversion: 9.5
46+
services:
47+
mysql:
48+
image: mysql:5.7
49+
env:
50+
MYSQL_ROOT_PASSWORD: root
51+
MYSQL_DATABASE: ${{ matrix.dbname }}
52+
ports:
53+
- 3306:3306
54+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
55+
postgres:
56+
image: postgres:9.5
57+
env:
58+
POSTGRES_USER: postgres
59+
POSTGRES_PASSWORD: password
60+
POSTGRES_DB: ${{ matrix.dbname }}
61+
ports:
62+
- 5432:5432
63+
# needed because the postgres container does not provide a healthcheck
64+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
65+
mailcatcher:
66+
image: schickling/mailcatcher
67+
ports:
68+
- 1080:1080
69+
- 1025:1025
70+
steps:
71+
- run: sudo apt-get purge -y hhvm
72+
- name: Checkout
73+
uses: actions/checkout@v2
74+
75+
- name: Setup PHP
76+
uses: nanasess/setup-php@master
77+
with:
78+
php-version: ${{ matrix.php }}
79+
80+
- name: Archive Plugin
81+
env:
82+
PLUGIN_CODE: ${{ matrix.plugin_code }}
83+
run: |
84+
tar cvzf ${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz ./*
85+
- name: Checkout EC-CUBE
86+
uses: actions/checkout@v2
87+
with:
88+
repository: 'EC-CUBE/ec-cube'
89+
ref: ${{ matrix.eccube_version }}
90+
path: 'ec-cube'
91+
92+
- name: Get Composer Cache Directory
93+
id: composer-cache
94+
run: |
95+
echo "::set-output name=dir::$(composer config cache-files-dir)"
96+
97+
- uses: actions/cache@v1
98+
with:
99+
path: ${{ steps.composer-cache.outputs.dir }}
100+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
101+
restore-keys: |
102+
${{ runner.os }}-composer-
103+
104+
- if: matrix.composer == 'v1'
105+
run: sudo composer selfupdate --1
106+
107+
- name: Install to composer
108+
working-directory: 'ec-cube'
109+
run: composer install --no-interaction -o --apcu-autoloader
110+
111+
- if: matrix.composer == 'v1'
112+
working-directory: 'ec-cube'
113+
run: composer require kiy0taka/eccube4-test-fixer "dev-main@dev"
114+
115+
- name: Setup EC-CUBE
116+
env:
117+
DB: ${{ matrix.db }}
118+
USER: ${{ matrix.dbuser }}
119+
DBUSER: ${{ matrix.dbuser }}
120+
DBPASS: ${{ matrix.dbpass }}
121+
DBNAME: ${{ matrix.dbname }}
122+
DBPORT: ${{ matrix.dbport }}
123+
DBSERVER: 127.0.0.1
124+
DBVERSION: ${{ matrix.dbversion }}
125+
ROOT_URLPATH: /ec-cube/html
126+
working-directory: 'ec-cube'
127+
run: |
128+
export PGPASSWORD=${DBPASS}
129+
echo "APP_ENV=prod" > .env
130+
echo "APP_DEBUG=0" >> .env
131+
echo "DATABASE_URL=${DB}://${DBUSER}:${DBPASS}@${DBSERVER}/${DBNAME}" >> .env
132+
echo "DATABASE_SERVER_VERSION=${DBVERSION}" >> .env
133+
echo "MAILER_URL=smtp://127.0.0.1:1025" >> .env
134+
echo "HTTP_SITEURL=https://localhost" >> .env
135+
echo "USE_SELFSIGNED_SSL_CERTIFICATE=1" >> .env
136+
cat .env
137+
bin/console doctrine:schema:create
138+
bin/console eccube:fixtures:load
139+
140+
- name: Setup Plugin
141+
env:
142+
PLUGIN_CODE: ${{ matrix.plugin_code }}
143+
working-directory: 'ec-cube'
144+
run: |
145+
bin/console eccube:plugin:install --code=${PLUGIN_CODE} --path=${GITHUB_WORKSPACE}/${PLUGIN_CODE}.tar.gz
146+
bin/console eccube:plugin:enable --code=${PLUGIN_CODE}
147+
rm codeception/_support/*Tester.php
148+
149+
- name: Run PHPUnit
150+
if: matrix.composer == 'v2'
151+
env:
152+
PLUGIN_CODE: ${{ matrix.plugin_code }}
153+
working-directory: 'ec-cube'
154+
run: bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests
155+
156+
- name: Run PHPUnit
157+
if: matrix.composer == 'v1'
158+
env:
159+
PLUGIN_CODE: ${{ matrix.plugin_code }}
160+
working-directory: 'ec-cube'
161+
run: |
162+
find app/Plugin/${PLUGIN_CODE}/Tests -name "*Test.php" | while read TESTCASE
163+
do
164+
./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}
165+
done
166+
167+
- name: Disable Plugin
168+
working-directory: 'ec-cube'
169+
env:
170+
PLUGIN_CODE: ${{ matrix.plugin_code }}
171+
run: bin/console eccube:plugin:disable --code=${PLUGIN_CODE}
172+
173+
- name: Uninstall Plugin
174+
env:
175+
PLUGIN_CODE: ${{ matrix.plugin_code }}
176+
working-directory: 'ec-cube'
177+
run: bin/console eccube:plugin:uninstall --code=${PLUGIN_CODE}

.travis.yml

Lines changed: 0 additions & 136 deletions
This file was deleted.

Entity/RelatedProduct.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313

1414
namespace Plugin\RelatedProduct4\Entity;
1515

16+
use Eccube\Entity\AbstractEntity;
1617
use Eccube\Entity\Product;
1718
use Doctrine\ORM\Mapping as ORM;
1819

1920
/**
2021
* Class RelatedProduct.
2122
*
2223
* @ORM\Table(name="plg_related_product")
23-
* @ORM\Entity(repositoryClass="Plugin\RelatedProduct\Repository\RelatedProductRepository")
24+
* @ORM\Entity(repositoryClass="Plugin\RelatedProduct4\Repository\RelatedProductRepository")
2425
*/
25-
class RelatedProduct
26+
class RelatedProduct extends AbstractEntity
2627
{
2728
/**
2829
* @var int

Form/Extension/Admin/RelatedCollectionExtension.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,14 @@ public function getExtendedType()
9999
{
100100
return ProductType::class;
101101
}
102+
103+
/**
104+
* product admin form name.
105+
*
106+
* @return string[]
107+
*/
108+
public static function getExtendedTypes()
109+
{
110+
yield ProductType::class;
111+
}
102112
}

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# 関連商品プラグイン
22

3-
[![Build Status](https://travis-ci.org/EC-CUBE/related-product-plugin.svg?branch=feature%2F1.0.0)](https://travis-ci.org/EC-CUBE/related-product-plugin)
4-
[![Build status](https://ci.appveyor.com/api/projects/status/oni9ptnqfs37uqdb?svg=true)](https://ci.appveyor.com/project/ECCUBE/related-product-plugin-9n48w)
5-
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/5c61b4f6-edad-4908-9a9a-6b4f38574a93/mini.png)](https://insight.sensiolabs.com/projects/5c61b4f6-edad-4908-9a9a-6b4f38574a93)
6-
[![Coverage Status](https://coveralls.io/repos/github/EC-CUBE/related-product-plugin/badge.svg)](https://coveralls.io/github/EC-CUBE/related-product-plugin)
3+
[![CI for RelatedProduct4](https://github.com/EC-CUBE/related-product-plugin/actions/workflows/main.yml/badge.svg)](https://github.com/EC-CUBE/related-product-plugin/actions/workflows/main.yml)
74

85
## 概要
96
商品詳細ページに、関連する商品を表示できるようになるプラグイン。

Tests/Web/RelatedProductAdminControllerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public function setUp()
6161
parent::setUp();
6262
$this->deleteAllRows(['plg_related_product']);
6363

64-
$this->productRepository = $this->container->get(ProductRepository::class);
65-
$this->relatedProductRepository = $this->container->get(RelatedProductRepository::class);
66-
$this->productStatusRepository = $this->container->get(ProductStatusRepository::class);
64+
$this->productRepository = $this->entityManager->getRepository(Product::class);
65+
$this->relatedProductRepository = $this->entityManager->getRepository(RelatedProduct::class);
66+
$this->productStatusRepository = $this->entityManager->getRepository(ProductStatus::class);
6767

6868
$this->Product = $this->createProduct('ディナーフォーク');
6969
$this->Category = $this->Product->getProductCategories()->current();
@@ -393,8 +393,8 @@ public function createFormData($content = null, $childId = 1)
393393
'product_image' => [],
394394
'description_detail' => $faker->realText,
395395
'description_list' => $faker->paragraph,
396-
'Category' => 1,
397-
'Tag' => 1,
396+
'Category' => [1],
397+
'Tag' => [1],
398398
'search_word' => $faker->word,
399399
'free_area' => $faker->realText,
400400
'Status' => 1,

Tests/Web/RelatedProductControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function setUp()
4040
{
4141
parent::setUp();
4242

43-
$this->productRepository = $this->container->get(ProductRepository::class);
43+
$this->productRepository = $this->entityManager->getRepository(Product::class);
4444
$this->Product = $this->createProduct('ディナーフォーク');
4545
}
4646

0 commit comments

Comments
 (0)