Skip to content

Commit 13dd676

Browse files
author
Krishna Kumar
committed
fixes for magento automation testing v4
1 parent 109f6ea commit 13dd676

File tree

7 files changed

+73
-11
lines changed

7 files changed

+73
-11
lines changed

app/code/Magento/LoginAsCustomerGraphQl/Model/LoginAsCustomer/CreateCustomerToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use Magento\Framework\Exception\LocalizedException;
1212
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1313
use Magento\Integration\Model\Oauth\TokenFactory;
14-
use Magento\Setup\Exception;
1514
use Magento\Store\Model\StoreManagerInterface;
15+
use Exception;
1616

1717
/**
1818
* Create customer token from customer email

app/code/Magento/LoginAsCustomerGraphQl/Model/Resolver/RequestCustomerToken.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
use Magento\Framework\Exception\NoSuchEntityException;
1313
use Magento\Framework\GraphQl\Config\Element\Field;
1414
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
15+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1516
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1617
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
1718
use Magento\Framework\GraphQl\Query\Resolver\Value;
1819
use Magento\Framework\GraphQl\Query\ResolverInterface;
1920
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
2021
use Magento\LoginAsCustomerApi\Api\ConfigInterface as LoginAsCustomerConfig;
2122
use Magento\LoginAsCustomerGraphQl\Model\LoginAsCustomer\CreateCustomerToken;
22-
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
2323

2424
/**
2525
* Gets customer token
@@ -29,17 +29,17 @@ class RequestCustomerToken implements ResolverInterface
2929
/**
3030
* @var LoginAsCustomerConfig
3131
*/
32-
private LoginAsCustomerConfig $config;
32+
private $config;
3333

3434
/**
3535
* @var AuthorizationInterface
3636
*/
37-
private AuthorizationInterface $authorization;
37+
private $authorization;
3838

3939
/**
4040
* @var CreateCustomerToken
4141
*/
42-
private CreateCustomerToken $createCustomerToken;
42+
private $createCustomerToken;
4343

4444
/**
4545
* RequestCustomerToken constructor.
@@ -67,7 +67,7 @@ public function __construct(
6767
* @param array|null $args
6868
* @return Value|mixed|void
6969
* @throws GraphQlAuthorizationException|GraphQlNoSuchEntityException|LocalizedException
70-
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
70+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
7171
*/
7272
public function resolve(
7373
Field $field,

app/code/Magento/LoginAsCustomerGraphQl/composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
"name": "magento/module-login-as-customer-graph-ql",
33
"description": "Flexible login as a customer so a merchant or merchant admin can log into an end customer's account to assist them with their account.",
44
"require": {
5-
"php": "~7.4.0",
5+
"php": "~7.3.0||~7.4.0",
66
"magento/framework": "102.0.*",
7+
"magento/module-login-as-customer-api": "100.4.*",
8+
"magento/module-integration": "100.4.*",
9+
"magento/module-store": "101.1.*",
710
"magento/module-customer": "103.0.*",
811
"magento/module-catalog-graph-ql": "100.4.*",
912
"magento/framework": "103.0.*"

dev/tests/api-functional/testsuite/Magento/GraphQl/LoginAsCustomer/GenerateLoginCustomerTokenTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ protected function setUp(): void
4141
* Verify with Admin email ID and Magento_LoginAsCustomer::login is enabled
4242
*
4343
* @magentoApiDataFixture Magento/LoginAsCustomer/_files/admin.php
44+
* @magentoApiDataFixture Magento/LoginAsCustomer/_files/login_as_customer_config_enable.php
4445
* @magentoApiDataFixture Magento/Customer/_files/customer.php
45-
* @magentoConfigFixture default_store login_as_customer/general/enabled 1
4646
* @throws Exception
4747
*/
4848
public function testGenerateCustomerValidTokenLoginAsCustomerEnabled()
@@ -65,15 +65,17 @@ public function testGenerateCustomerValidTokenLoginAsCustomerEnabled()
6565
* Verify with Admin email ID and Magento_LoginAsCustomer::login is disabled
6666
*
6767
* @magentoApiDataFixture Magento/LoginAsCustomer/_files/admin.php
68+
* @magentoApiDataFixture Magento/LoginAsCustomer/_files/login_as_customer_config_disable.php
6869
* @magentoApiDataFixture Magento/Customer/_files/customer.php
69-
* @magentoConfigFixture default_store login_as_customer/general/enabled 0
7070
* @throws Exception
7171
*/
7272
public function testGenerateCustomerValidTokenLoginAsCustomerDisabled()
7373
{
7474
$customerEmail = '[email protected]';
7575

7676
$mutation = $this->getQuery($customerEmail);
77+
$this->expectException(Exception::class);
78+
$this->expectExceptionMessage("Login as Customer is disabled..");
7779

7880
$response = $this->graphQlMutation(
7981
$mutation,
@@ -89,7 +91,7 @@ public function testGenerateCustomerValidTokenLoginAsCustomerDisabled()
8991
* Verify with Customer Token in auth header
9092
*
9193
* @magentoApiDataFixture Magento/Customer/_files/customer.php
92-
* @magentoConfigFixture default_store login_as_customer/general/enabled 1
94+
* @magentoApiDataFixture Magento/LoginAsCustomer/_files/login_as_customer_config_enable.php
9395
* @throws Exception
9496
*/
9597
public function testGenerateCustomerTokenLoginWithCustomerCredentials()
@@ -116,7 +118,7 @@ public function testGenerateCustomerTokenLoginWithCustomerCredentials()
116118
* Test with invalid data.
117119
*
118120
* @magentoApiDataFixture Magento/LoginAsCustomer/_files/admin.php
119-
* @magentoConfigFixture default_store login_as_customer/general/enabled 1
121+
* @magentoApiDataFixture Magento/LoginAsCustomer/_files/login_as_customer_config_enable.php
120122
*
121123
* @dataProvider dataProviderInvalidInfo
122124
* @param string $adminUserName
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
use Magento\Config\Model\Config\Factory as ConfigFactory;
7+
8+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
9+
10+
$loginAsCustomerConfigPath = 'login_as_customer/general/enabled';
11+
/** @var ConfigFactory $configFactory */
12+
$configFactory = $objectManager->get(ConfigFactory::class);
13+
14+
$configModel = $configFactory->create();
15+
$configModel->setDataByPath($loginAsCustomerConfigPath, 0);
16+
try {
17+
$configModel->save();
18+
} catch (Exception $e) {
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
use Magento\Config\Model\Config\Factory as ConfigFactory;
7+
8+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
9+
10+
$loginAsCustomerConfigPath = 'login_as_customer/general/enabled';
11+
/** @var ConfigFactory $configFactory */
12+
$configFactory = $objectManager->get(ConfigFactory::class);
13+
14+
$configModel = $configFactory->create();
15+
$configModel->setDataByPath($loginAsCustomerConfigPath, 1);
16+
try {
17+
$configModel->save();
18+
} catch (Exception $e) {
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
use Magento\Config\Model\Config\Factory as ConfigFactory;
7+
8+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
9+
10+
$loginAsCustomerConfigPath = 'login_as_customer/general/enabled';
11+
/** @var ConfigFactory $configFactory */
12+
$configFactory = $objectManager->get(ConfigFactory::class);
13+
14+
$configModel = $configFactory->create();
15+
$configModel->setDataByPath($loginAsCustomerConfigPath, 0);
16+
try {
17+
$configModel->save();
18+
} catch (Exception $e) {
19+
}

0 commit comments

Comments
 (0)