Skip to content

Commit d4f99d8

Browse files
committed
Merge remote-tracking branch 'origin/MC-17269' into 2.3-develop-pr53
2 parents fdfb142 + 22f53db commit d4f99d8

23 files changed

+140
-330
lines changed

app/code/Magento/Backend/Test/Mftf/ActionGroup/SetAdminAccountActionGroup.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="SetAdminAccountActionGroup">
1212
<arguments>
13-
<argument name="InterfaceLocaleByValue" type="string"/>
13+
<argument name="InterfaceLocaleByValue" defaultValue="en_US" type="string"/>
1414
</arguments>
1515
<!-- Navigate to admin System Account Page-->
1616
<amOnPage url="{{AdminSystemAccountPage.url}}" stepKey="openAdminSystemAccountPage" />
1717
<waitForElementVisible selector="{{AdminSystemAccountSection.interfaceLocale}}" stepKey="waitForInterfaceLocale"/>
18+
<!-- Change Admin locale to Français (France) / French (France) -->
1819
<selectOption userInput="{{InterfaceLocaleByValue}}" selector="{{AdminSystemAccountSection.interfaceLocale}}" stepKey="setInterfaceLocate"/>
1920
<fillField selector="{{AdminSystemAccountSection.currentPassword}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="fillPassword"/>
2021
<click selector="{{AdminMainActionsSection.save}}" stepKey="clickSave"/>
21-
<waitForElement selector="{{AdminMessagesSection.successMessage}}" stepKey="waitSuccessMessage"/>
22-
<see selector="{{AdminMessagesSection.successMessage}}" userInput="You saved the account." stepKey="seeSuccessMessage"/>
22+
<waitForElementVisible selector="{{AdminMessagesSection.success}}" stepKey="waitSuccessMessage"/>
23+
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the account." stepKey="seeSuccessMessage"/>
2324
</actionGroup>
2425
</actionGroups>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenCmsBlockActionGroup">
11+
<arguments>
12+
<argument name="block_id" type="string"/>
13+
</arguments>
14+
<amOnPage url="{{AdminEditBlockPage.url(block_id)}}" stepKey="openEditCmsBlock"/>
15+
</actionGroup>
16+
</actionGroups>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenCmsBlockActionGroup">
11+
<arguments>
12+
<argument name="block_id" type="string"/>
13+
</arguments>
14+
<amOnPage url="{{AdminEditBlockPage.url(block_id)}}" stepKey="openEditCmsBlock"/>
15+
</actionGroup>
16+
</actionGroups>

app/code/Magento/Cms/Test/Mftf/Data/BlockPageData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
1111
<entity name="_defaultBlock" type="block">
12-
<data key="title">Default Block</data>
12+
<data key="title" unique="suffix">Default Block</data>
1313
<data key="identifier" unique="suffix" >block</data>
1414
<data key="content">Here is a block test. Yeah!</data>
1515
<data key="active">true</data>

app/code/Magento/Cms/Test/Mftf/Page/AdminCmsEditBlockPage.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
11-
<page name="AdminEditBlockPage" url="cms/block/edit/block_id" area="admin" module="Magento_Cms">
11+
<page name="AdminEditBlockPage" url="cms/block/edit/block_id/{{id}}" area="admin" module="Magento_Cms" parameterized="true">
1212
<section name="AdminUpdateBlockSection"/>
1313
</page>
1414
</pages>

app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridTableSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
<element name="rowViewAction" type="button" selector=".data-grid tbody > tr:nth-of-type({{row}}) .action-menu-item" parameterized="true" timeout="30"/>
2121
<element name="dataGridEmpty" type="block" selector=".data-grid-tr-no-data td"/>
2222
<element name="rowTemplateStrict" type="block" selector="//tbody/tr[td[*[text()[normalize-space()='{{text}}']]]]" parameterized="true" />
23-
<element name="rowTemplate" type="block" selector="//tbody/tr[td[*[contains(.,normalize-space('{{text}}'))]]]" parameterized="true" />
23+
<element name="rowTemplate" type="block" selector="//tbody/tr[td[*[contains(.,normalize-space('{{text}}'))]]]" parameterized="true" timeout="30" />
2424
</section>
2525
</sections>

dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Customer/PlaceOrderWithAuthorizeNetTest.php

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@
77

88
namespace Magento\AuthorizenetGraphQl\Model\Resolver\Customer;
99

10-
use Magento\Framework\App\Request\Http;
1110
use Magento\Framework\Serialize\SerializerInterface;
12-
use Magento\GraphQl\Controller\GraphQl;
1311
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
12+
use Magento\GraphQl\Service\GraphQlRequest;
1413
use Magento\Integration\Api\CustomerTokenServiceInterface;
15-
use Magento\Framework\Webapi\Request;
1614
use Magento\TestFramework\Helper\Bootstrap;
1715
use Magento\Framework\HTTP\ZendClient;
1816
use Magento\Framework\HTTP\ZendClientFactory;
1917
use Magento\TestFramework\ObjectManager;
2018
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
21-
use Magento\Payment\Gateway\Data\PaymentDataObjectFactory;
2219
use PHPUnit\Framework\MockObject\MockObject;
23-
use Magento\Quote\Model\Quote\PaymentFactory;
2420
use PHPUnit\Framework\TestCase;
2521
use Zend_Http_Response;
2622

@@ -29,41 +25,35 @@
2925
*
3026
* @magentoAppArea graphql
3127
* @magentoDbIsolation disabled
32-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3328
*/
3429
class PlaceOrderWithAuthorizeNetTest extends TestCase
3530
{
36-
const CONTENT_TYPE = 'application/json';
37-
38-
/** @var ObjectManager */
31+
/** @var ObjectManager */
3932
private $objectManager;
4033

41-
/** @var GetMaskedQuoteIdByReservedOrderId */
34+
/** @var GetMaskedQuoteIdByReservedOrderId */
4235
private $getMaskedQuoteIdByReservedOrderId;
4336

4437
/** @var SerializerInterface */
4538
private $jsonSerializer;
4639

47-
/** @var Http */
48-
private $request;
40+
/** @var GraphQlRequest */
41+
private $graphQlRequest;
4942

5043
/** @var ZendClient|MockObject|InvocationMocker */
5144
private $clientMock;
5245

53-
/** @var CustomerTokenServiceInterface */
46+
/** @var CustomerTokenServiceInterface */
5447
private $customerTokenService;
5548

5649
/** @var Zend_Http_Response */
5750
protected $responseMock;
5851

59-
/** @var PaymentFactory */
60-
private $paymentFactory;
61-
6252
protected function setUp() : void
6353
{
6454
$this->objectManager = Bootstrap::getObjectManager();
6555
$this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
66-
$this->request = $this->objectManager->get(Http::class);
56+
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
6757
$this->getMaskedQuoteIdByReservedOrderId = $this->objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
6858
$this->customerTokenService = $this->objectManager->get(CustomerTokenServiceInterface::class);
6959
$this->clientMock = $this->createMock(ZendClient::class);
@@ -75,8 +65,6 @@ protected function setUp() : void
7565
$clientFactoryMock = $this->createMock(ZendClientFactory::class);
7666
$clientFactoryMock->method('create')
7767
->willReturn($this->clientMock);
78-
/** @var PaymentDataObjectFactory $paymentFactory */
79-
$this->paymentFactory = $this->objectManager->get(PaymentDataObjectFactory::class);
8068
$this->objectManager->addSharedInstance($clientFactoryMock, ZendClientFactory::class);
8169
}
8270

@@ -126,23 +114,12 @@ public function testDispatchToPlaceOrderWithRegisteredCustomer(): void
126114
}
127115
}
128116
QUERY;
129-
$postData = [
130-
'query' => $query,
131-
'variables' => null,
132-
'operationName' => null
133-
];
134-
$this->request->setPathInfo('/graphql');
135-
$this->request->setMethod('POST');
136-
$this->request->setContent($this->jsonSerializer->serialize($postData));
137-
$customerToken = $this->customerTokenService->createCustomerAccessToken('customer@example.com', 'password');
138-
$bearerCustomerToken = 'Bearer ' . $customerToken;
139-
$webApiRequest = $this->objectManager->get(Request::class);
140-
$webApiRequest->getHeaders()->addHeaderLine('Content-Type', 'application/json')
141-
->addHeaderLine('Accept', 'application/json')
142-
->addHeaderLine('Authorization', $bearerCustomerToken);
143-
$this->request->setHeaders($webApiRequest->getHeaders());
144-
$graphql = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class);
145117

118+
$customerToken = $this->customerTokenService->createCustomerAccessToken('customer@example.com', 'password');
119+
$requestHeaders = [
120+
'Accept' => 'application/json',
121+
'Authorization' => 'Bearer ' . $customerToken
122+
];
146123
// phpcs:ignore Magento2.Security.IncludeFile
147124
$expectedRequest = include __DIR__ . '/../../../_files/request_authorize_customer.php';
148125
// phpcs:ignore Magento2.Security.IncludeFile
@@ -153,7 +130,7 @@ public function testDispatchToPlaceOrderWithRegisteredCustomer(): void
153130

154131
$this->responseMock->method('getBody')->willReturn(json_encode($authorizeResponse));
155132

156-
$response = $graphql->dispatch($this->request);
133+
$response = $this->graphQlRequest->send($query, [], '', $requestHeaders);
157134
$responseData = $this->jsonSerializer->unserialize($response->getContent());
158135

159136
$this->assertArrayNotHasKey('errors', $responseData, 'Response has errors');
@@ -178,6 +155,5 @@ public function testDispatchToPlaceOrderWithRegisteredCustomer(): void
178155
protected function tearDown()
179156
{
180157
$this->objectManager->removeSharedInstance(ZendClientFactory::class);
181-
parent::tearDown();
182158
}
183159
}

dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Customer/SetAuthorizeNetPaymentMethodOnCartTest.php

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77

88
namespace Magento\AuthorizenetGraphQl\Model\Resolver\Customer;
99

10-
use Magento\Framework\App\Request\Http;
1110
use Magento\Framework\Serialize\SerializerInterface;
12-
use Magento\Framework\Webapi\Request;
1311
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
12+
use Magento\GraphQl\Service\GraphQlRequest;
1413
use Magento\Integration\Api\CustomerTokenServiceInterface;
1514
use Magento\TestFramework\Helper\Bootstrap;
1615
use PHPUnit\Framework\TestCase;
@@ -20,32 +19,29 @@
2019
*
2120
* @magentoAppArea graphql
2221
* @magentoDbIsolation disabled
23-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2422
*/
2523
class SetAuthorizeNetPaymentMethodOnCartTest extends TestCase
2624
{
27-
const CONTENT_TYPE = 'application/json';
28-
2925
/** @var \Magento\Framework\ObjectManagerInterface */
3026
private $objectManager;
3127

32-
/** @var GetMaskedQuoteIdByReservedOrderId */
28+
/** @var GetMaskedQuoteIdByReservedOrderId */
3329
private $getMaskedQuoteIdByReservedOrderId;
3430

3531
/** @var SerializerInterface */
3632
private $jsonSerializer;
3733

38-
/** @var CustomerTokenServiceInterface */
34+
/** @var CustomerTokenServiceInterface */
3935
private $customerTokenService;
4036

41-
/** @var Http */
42-
private $request;
37+
/** @var GraphQlRequest */
38+
private $graphQlRequest;
4339

4440
protected function setUp() : void
4541
{
4642
$this->objectManager = Bootstrap::getObjectManager();
4743
$this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
48-
$this->request = $this->objectManager->get(Http::class);
44+
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
4945
$this->getMaskedQuoteIdByReservedOrderId = $this->objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
5046
$this->customerTokenService = $this->objectManager->get(CustomerTokenServiceInterface::class);
5147
}
@@ -88,24 +84,16 @@ public function testDispatchToSetPaymentMethodWithAuthorizenet(): void
8884
}
8985
}
9086
QUERY;
91-
$postData = [
92-
'query' => $query,
93-
'variables' => null,
94-
'operationName' => null
95-
];
96-
$this->request->setPathInfo('/graphql');
97-
$this->request->setMethod('POST');
98-
$this->request->setContent($this->jsonSerializer->serialize($postData));
87+
9988
$customerToken = $this->customerTokenService->createCustomerAccessToken('customer@example.com', 'password');
100-
$bearerCustomerToken = 'Bearer ' . $customerToken;
101-
$contentType ='application/json';
102-
$webApiRequest = $this->objectManager->get(Request::class);
103-
$webApiRequest->getHeaders()->addHeaderLine('Content-Type', $contentType)
104-
->addHeaderLine('Accept', $contentType)
105-
->addHeaderLine('Authorization', $bearerCustomerToken);
106-
$this->request->setHeaders($webApiRequest->getHeaders());
107-
$graphql = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class);
108-
$response = $graphql->dispatch($this->request);
89+
90+
$requestHeaders = [
91+
'Accept' => 'application/json',
92+
'Authorization' => 'Bearer ' . $customerToken
93+
];
94+
95+
$response = $this->graphQlRequest->send($query, [], '', $requestHeaders);
96+
10997
$output = $this->jsonSerializer->unserialize($response->getContent());
11098
$this->assertArrayNotHasKey('errors', $output, 'Response has errors');
11199
$this->assertArrayHasKey('setPaymentMethodOnCart', $output['data']);

0 commit comments

Comments
 (0)