From c0d1b7b7400dd53e78e15b42d68c6bf4df46b195 Mon Sep 17 00:00:00 2001 From: Pablo Fantini Date: Wed, 12 Sep 2018 12:15:23 -0300 Subject: [PATCH] GrapgQL-129: Add composer dependency and fix codestyle issues --- .../Customer/Account/GenerateCustomerToken.php | 16 ++++------------ app/code/Magento/CustomerGraphQl/composer.json | 1 + .../Customer/GenerateCustomerTokenTest.php | 4 ++-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/CustomerGraphQl/Model/Resolver/Customer/Account/GenerateCustomerToken.php b/app/code/Magento/CustomerGraphQl/Model/Resolver/Customer/Account/GenerateCustomerToken.php index 466aad1c0348f..15012ca1364a0 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Resolver/Customer/Account/GenerateCustomerToken.php +++ b/app/code/Magento/CustomerGraphQl/Model/Resolver/Customer/Account/GenerateCustomerToken.php @@ -7,11 +7,10 @@ namespace Magento\CustomerGraphQl\Model\Resolver\Customer\Account; -use Magento\Authorization\Model\UserContextInterface; use Magento\Integration\Api\CustomerTokenServiceInterface; -use Magento\Customer\Model\Customer; use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException; +use Magento\Framework\Exception\AuthenticationException; use Magento\Framework\GraphQl\Query\Resolver\Value; use Magento\Framework\GraphQl\Query\Resolver\ValueFactory; use Magento\Framework\GraphQl\Query\ResolverInterface; @@ -19,10 +18,6 @@ class GenerateCustomerToken implements ResolverInterface { - /** - * @var UserContextInterface - */ - private $userContext; /** * @var CustomerTokenServiceInterface @@ -35,18 +30,15 @@ class GenerateCustomerToken implements ResolverInterface private $valueFactory; /** - * @param UserContextInterface $userContext * @param CustomerTokenServiceInterface $customerTokenService - * @param ValueFactory $valueFactory + * @param ValueFactory $valueFactory */ public function __construct( - UserContextInterface $userContext, CustomerTokenServiceInterface $customerTokenService, ValueFactory $valueFactory ) { - $this->userContext = $userContext; $this->customerTokenService = $customerTokenService; - $this->valueFactory = $valueFactory; + $this->valueFactory = $valueFactory; } /** @@ -65,7 +57,7 @@ public function resolve( return !empty($token) ? $token : ''; }; return $this->valueFactory->create($result); - }catch (\Magento\Framework\Exception\AuthenticationException $e){ + } catch (AuthenticationException $e) { throw new GraphQlAuthorizationException( __($e->getMessage()) ); diff --git a/app/code/Magento/CustomerGraphQl/composer.json b/app/code/Magento/CustomerGraphQl/composer.json index 290d925215ec2..c26c83c95be38 100644 --- a/app/code/Magento/CustomerGraphQl/composer.json +++ b/app/code/Magento/CustomerGraphQl/composer.json @@ -6,6 +6,7 @@ "php": "~7.1.3||~7.2.0", "magento/module-customer": "*", "magento/module-authorization": "*", + "magento/module-integration": "*", "magento/framework": "*" }, "suggest": { diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GenerateCustomerTokenTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GenerateCustomerTokenTest.php index 6aa970037fe5f..44b7925ec4e42 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GenerateCustomerTokenTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GenerateCustomerTokenTest.php @@ -59,8 +59,8 @@ public function testGenerateCustomerTokenWithInvalidCredentials() MUTATION; $this->expectException(\Exception::class); - $this->expectExceptionMessage('GraphQL response contains errors: ' . - 'The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.'); + $this->expectExceptionMessage('GraphQL response contains errors: The account sign-in' . ' ' . + 'was incorrect or your account is disabled temporarily. Please wait and try again later.'); $this->graphQlQuery($mutation); } }