Skip to content

Commit

Permalink
Merge pull request EC-CUBE#106 from nanasess/improve/4.1
Browse files Browse the repository at this point in the history
EC-CUBE4.1対応
  • Loading branch information
okazy authored Dec 1, 2020
2 parents 726a29e + 09a0df0 commit 96f3d27
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 43 deletions.
24 changes: 18 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ env:
PLUGIN_CODE=Api
ECCUBE_PACKAGE_API_URL=http://127.0.0.1:8080
matrix:
- DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5
- DATABASE_URL=postgres://postgres:password@localhost/cube4_dev DATABASE_SERVER_VERSION=9
- ECCUBE_VERSION=4.0.5 DATABASE_URL=mysql://root:@localhost/cube4_dev DATABASE_SERVER_VERSION=5
- ECCUBE_VERSION=4.0.5 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

before_install: &php_setup |
echo "opcache.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
Expand All @@ -37,8 +39,9 @@ install_eccube: &install_eccube |
tar cvzf ${HOME}/${PLUGIN_CODE}.tar.gz ./*
git clone https://github.com/EC-CUBE/ec-cube.git
cd ec-cube
git checkout experimental/plugin_bundle
composer selfupdate --1
git checkout ${ECCUBE_VERSION}
if [[ $ECCUBE_VERSION = '4.0.5' ]]; then composer selfupdate --1 ; fi
if [[ $ECCUBE_VERSION = '4.1' ]]; then composer selfupdate ; fi
composer install --dev --no-interaction -o --apcu-autoloader

package_api_setup: &package_api_setup |
Expand All @@ -62,9 +65,18 @@ install:
- *install_eccube
- *package_api_setup
- *eccube_setup
- composer require --dev kiy0taka/eccube4-test-fixer

script:
- ./vendor/bin/phpunit app/Plugin/${PLUGIN_CODE}/Tests;
script: |
if [[ $ECCUBE_VERSION = '4.0.5' ]]
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
1 change: 1 addition & 0 deletions DependencyInjection/ApiExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function prepend(ContainerBuilder $container)
'security' => true,
'stateless' => true,
'oauth2' => true,
'provider' => 'member_provider'
];
}
$replaced[$name] = $origin[$name];
Expand Down
6 changes: 3 additions & 3 deletions GraphQL/Mutation/UpdateProductStockMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Plugin\Api\GraphQL\Mutation;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Eccube\Entity\ProductClass;
use Eccube\Repository\ProductClassRepository;
use GraphQL\Type\Definition\Type;
Expand All @@ -34,14 +34,14 @@ class UpdateProductStockMutation implements Mutation
private $productClassRepository;

/**
* @var EntityManager
* @var EntityManagerInterface
*/
private $entityManager;

public function __construct(
Types $types,
ProductClassRepository $productClassRepository,
EntityManager $entityManager
EntityManagerInterface $entityManager
) {
$this->types = $types;
$this->productClassRepository = $productClassRepository;
Expand Down
6 changes: 3 additions & 3 deletions GraphQL/Mutation/UpdateShippedMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Plugin\Api\GraphQL\Mutation;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Eccube\Common\EccubeConfig;
use Eccube\Entity\Master\OrderStatus;
use Eccube\Entity\Order;
Expand All @@ -40,7 +40,7 @@ class UpdateShippedMutation implements Mutation
private $eccubeConfig;

/**
* @var EntityManager
* @var EntityManagerInterface
*/
private $entityManager;

Expand Down Expand Up @@ -71,7 +71,7 @@ class UpdateShippedMutation implements Mutation

public function __construct(
EccubeConfig $eccubeConfig,
EntityManager $entityManager,
EntityManagerInterface $entityManager,
MailService $mailService,
OrderStateMachine $orderStateMachine,
OrderStatusRepository $orderStatusRepository,
Expand Down
12 changes: 6 additions & 6 deletions GraphQL/Query/SearchFormQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
use Eccube\Common\EccubeConfig;
use Eccube\Util\StringUtil;
use GraphQL\Type\Definition\Type;
use Knp\Component\Pager\Paginator;
use Knp\Component\Pager\PaginatorInterface;
use Plugin\Api\GraphQL\Error\InvalidArgumentException;
use Plugin\Api\GraphQL\Query;
use Plugin\Api\GraphQL\Type\ConnectionType;
use Plugin\Api\GraphQL\Types;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Validator\Constraints as Assert;

abstract class SearchFormQuery implements Query
{
/**
* @var Paginator
* @var PaginatorInterface
*/
private $paginator;

Expand All @@ -41,7 +41,7 @@ abstract class SearchFormQuery implements Query
private $eccubeConfig;

/**
* @var FormFactory
* @var FormFactoryInterface
*/
private $formFactory;

Expand All @@ -53,7 +53,7 @@ abstract class SearchFormQuery implements Query
/**
* @required
*/
public function setPaginator(Paginator $paginator): void
public function setPaginator(PaginatorInterface $paginator): void
{
$this->paginator = $paginator;
}
Expand All @@ -69,7 +69,7 @@ public function setEccubeConfig(EccubeConfig $eccubeConfig): void
/**
* @required
*/
public function setFormFactory(FormFactory $formFactory): void
public function setFormFactory(FormFactoryInterface $formFactory): void
{
$this->formFactory = $formFactory;
}
Expand Down
3 changes: 3 additions & 0 deletions Resource/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ services:
nyholm.psr7.httplug_factory:
class: Nyholm\Psr7\Factory\HttplugFactory


Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory: '@sensio_framework_extra.psr7.http_message_factory'

core.api.allow_list:
class: ArrayObject
tags: ['eccube.api.allow_list']
Expand Down
6 changes: 3 additions & 3 deletions Resource/locale/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ api:
secret_tooltip: Up to 128 alphanumeric characters
scope: Scope
scope_tooltip: GraphQL Query requires read, Mutation requires write/write Scope
scope.read.description: Read %shop_name% data
scope.write.description: Write %shop_name% data
scope.read.description: 'Read %shop_name% data'
scope.write.description: 'Write %shop_name% data'
redirect_uri: Redirect URI
redirect_uri_tooltip: You can enter multiple URIs separated by commas
grant_type: Grant Type
Expand All @@ -26,7 +26,7 @@ api:
clear_expired_tokens: Clears all expired access and/or refresh tokens
copy: Copy
copied: Copied
allow__confirm_message: Do you want to allow access this app to %shop_name%?
allow__confirm_message: 'Do you want to allow access this app to %shop_name%?'
allow__confirm_description: 'Allow this app to:'
allow: Allow
deny: Deny
Expand Down
6 changes: 3 additions & 3 deletions Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ api:
secret_tooltip: 128文字以下の半角英数
scope: スコープ
scope_tooltip: GraphQLのQueryにはread, Mutationにはwrite/writeのScopeが必要
scope.read.description: %shop_name%のデータに対する読み取り
scope.write.description: %shop_name%のデータに対する書き込み
scope.read.description: '%shop_name%のデータに対する読み取り'
scope.write.description: '%shop_name%のデータに対する書き込み'
redirect_uri: リダイレクトURI
redirect_uri_tooltip: カンマ区切りで複数のURIを入力可能
grant_type: グラントタイプ
Expand All @@ -26,7 +26,7 @@ api:
clear_expired_tokens: 期限切れのアクセストークンとリフレッシュトークンを削除する
copy: コピーする
copied: コピーしました
allow__confirm_message: アプリから%shop_name%へのアクセスを許可しますか?
allow__confirm_message: 'アプリから%shop_name%へのアクセスを許可しますか?'
allow__confirm_description: 'このアプリに以下を許可します:'
allow: 許可する
deny: 許可しない
Expand Down
4 changes: 2 additions & 2 deletions Tests/GraphQL/Mutation/UpdateProductStockMutationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class UpdateProductStockMutationTest extends EccubeTestCase
public function setUp()
{
parent::setUp();
$types = $this->container->get(Types::class);
$this->productClassRepository = $this->container->get(ProductClassRepository::class);
$types = self::$container->get(Types::class);
$this->productClassRepository = self::$container->get(ProductClassRepository::class);
$this->updateProductStockMutation = new UpdateProductStockMutation($types, $this->productClassRepository, $this->entityManager);

// テスト用の商品を作成
Expand Down
10 changes: 5 additions & 5 deletions Tests/GraphQL/Mutation/UpdateShippedMutationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public function setUp()
{
parent::setUp();

$mailService = $this->container->get(MailService::class);
$orderStateMachine = $this->container->get(OrderStateMachine::class);
$orderStatusRepository = $this->container->get(OrderStatusRepository::class);
$types = $this->container->get(Types::class);
$shippingRepository = $this->container->get(ShippingRepository::class);
$mailService = self::$container->get(MailService::class);
$orderStateMachine = self::$container->get(OrderStateMachine::class);
$orderStatusRepository = self::$container->get(OrderStatusRepository::class);
$types = self::$container->get(Types::class);
$shippingRepository = self::$container->get(ShippingRepository::class);

$this->updateShippedMutation = new UpdateShippedMutation(
$this->eccubeConfig,
Expand Down
2 changes: 1 addition & 1 deletion Tests/GraphQL/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ private function executeQuery($query, $variables = null, $readonly = false)
{
$op = OperationParams::create(['query' => $query, 'variables' => $variables], $readonly);
$helper = new Helper();
$config = ServerConfig::create()->setSchema($this->container->get(Schema::class));
$config = ServerConfig::create()->setSchema(self::$container->get(Schema::class));
$result = $helper->executeOperation($config, $op);
self::assertInstanceOf(ExecutionResult::class, $result);

Expand Down
2 changes: 1 addition & 1 deletion Tests/GraphQL/TypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TypesTest extends EccubeTestCase
public function setUp()
{
parent::setUp();
$this->types = $this->container->get(Types::class);
$this->types = self::$container->get(Types::class);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Tests/Service/WebHookServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function setUp()
{
parent::setUp();

$this->service = $this->container->get(WebHookService::class);
$this->service = self::$container->get(WebHookService::class);
}

public function testCreateRequest_withSecret()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Web/Admin/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testRoutingAdminLoginCheck()
]
);

$this->assertNotNull($this->container->get('security.token_storage')->getToken(), 'ログインしているかどうか');
$this->assertNotNull(self::$container->get('security.token_storage')->getToken(), 'ログインしているかどうか');
}

public function testRoutingAdminLogin_ログインしていない場合はログイン画面を表示()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Web/Admin/OAuthControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function setUp()
{
parent::setUp();

$this->clientManager = $this->container->get(ClientManager::class);
$this->clientManager = self::$container->get(ClientManager::class);
}

public function testRoutingAdminSettingSystemOAuth2Client()
Expand Down
8 changes: 4 additions & 4 deletions Tests/Web/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class ApiControllerTest extends AbstractWebTestCase
public function setUp()
{
parent::setUp();
$this->clientManager = $this->container->get(ClientManager::class);
$this->clientRepository = $this->container->get(ClientRepositoryInterface::class);
$this->accessTokenRepository = $this->container->get(AccessTokenRepositoryInterface::class);
$this->authorizationServer = $this->container->get(AuthorizationServer::class);
$this->clientManager = self::$container->get(ClientManager::class);
$this->clientRepository = self::$container->get(ClientRepositoryInterface::class);
$this->accessTokenRepository = self::$container->get(AccessTokenRepositoryInterface::class);
$this->authorizationServer = self::$container->get(AuthorizationServer::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/Api",
"version": "1.0.0",
"name": "ec-cube/api",
"version": "2.0.0",
"description": "Web API",
"type": "eccube-plugin",
"require": {
"ec-cube/plugin-installer": "~0.0.6",
"ec-cube/plugin-installer": "~0.0.6 || ^2.0@dev",
"trikoder/oauth2-bundle": "^2.1",
"nyholm/psr7": "^1.2",
"webonyx/graphql-php": "^14.0"
Expand Down

0 comments on commit 96f3d27

Please sign in to comment.