Skip to content

Commit 8dd44d0

Browse files
merge magento/2.3-develop into magento-epam/EPAM-PR-44
2 parents 53a76b5 + ee8bd11 commit 8dd44d0

30 files changed

+1022
-660
lines changed

app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateAndSwitchProductType.xml

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<group value="catalog"/>
5555
<group value="mtf_migrated"/>
5656
<skip>
57-
<issueId value="MAGETWO-62808"/>
57+
<issueId value="MSI-2110"/>
5858
</skip>
5959
</annotations>
6060
<before>
@@ -83,4 +83,120 @@
8383
<argument name="optionName" value="$createConfigProductAttributeOption1.option[store_labels][1][label]$"/>
8484
</actionGroup>
8585
</test>
86+
<test name="AdminCreateSimpleProductSwitchToConfigurableTest" extends="AdminCreateSimpleProductSwitchToVirtualTest">
87+
<annotations>
88+
<features value="Catalog"/>
89+
<stories value="Product Type Switching"/>
90+
<title value="Admin should be able to switch a new product from simple to configurable"/>
91+
<description value="After selecting a simple product when adding Admin should be switch to configurable implicitly"/>
92+
<severity value="CRITICAL"/>
93+
<useCaseId value="MAGETWO-44165"/>
94+
<testCaseId value="MAGETWO-29398"/>
95+
<group value="catalog"/>
96+
<group value="mtf_migrated"/>
97+
<skip>
98+
<issueId value="MSI-2110"/>
99+
</skip>
100+
</annotations>
101+
<before>
102+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
103+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
104+
<requiredEntity createDataKey="createConfigProductAttribute"/>
105+
</createData>
106+
</before>
107+
<after>
108+
<deleteData stepKey="deleteAttribute" createDataKey="createConfigProductAttribute"/>
109+
</after>
110+
<actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="openProductFillForm">
111+
<argument name="productType" value="simple"/>
112+
</actionGroup>
113+
<!-- Create configurable product from simple product page-->
114+
<comment userInput="Create configurable product" stepKey="commentCreateProduct"/>
115+
<actionGroup ref="fillMainProductForm" stepKey="fillProductForm">
116+
<argument name="product" value="_defaultProduct"/>
117+
</actionGroup>
118+
<comment before="createConfiguration" stepKey="beforeCreateConfiguration" userInput="Adding Configuration to Product"/>
119+
<actionGroup ref="generateConfigurationsByAttributeCode" stepKey="createConfiguration" after="fillProductForm">
120+
<argument name="attributeCode" value="$$createConfigProductAttribute.attribute_code$$"/>
121+
</actionGroup>
122+
<actionGroup ref="saveConfiguredProduct" stepKey="saveProductForm"/>
123+
<see selector="{{AdminProductGridSection.productGridCell('2', 'Type')}}" userInput="Configurable Product" stepKey="seeProductTypeInGrid"/>
124+
<!-- Verify product on store front -->
125+
<comment userInput="Verify product on store front" stepKey="commentVerifyProductGrid"/>
126+
<actionGroup ref="VerifyOptionInProductStorefront" stepKey="verifyConfigurableOption" after="AssertProductInStorefrontProductPage">
127+
<argument name="attributeCode" value="$createConfigProductAttribute.default_frontend_label$"/>
128+
<argument name="optionName" value="$createConfigProductAttributeOption1.option[store_labels][1][label]$"/>
129+
</actionGroup>
130+
</test>
131+
<test name="AdminCreateDownloadableProductSwitchToConfigurableTest">
132+
<annotations>
133+
<features value="Catalog"/>
134+
<stories value="Product Type Switching"/>
135+
<title value="Admin should be able to switch a new product from downloadable to configurable"/>
136+
<description value="After selecting a downloadable product when adding Admin should be switch to configurable implicitly"/>
137+
<severity value="CRITICAL"/>
138+
<useCaseId value="MAGETWO-44165"/>
139+
<testCaseId value="MAGETWO-29398"/>
140+
<group value="catalog"/>
141+
<group value="mtf_migrated"/>
142+
<skip>
143+
<issueId value="MSI-2110"/>
144+
</skip>
145+
</annotations>
146+
<before>
147+
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/>
148+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
149+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
150+
<requiredEntity createDataKey="createConfigProductAttribute"/>
151+
</createData>
152+
</before>
153+
<after>
154+
<actionGroup ref="GoToProductCatalogPage" stepKey="goToProductCatalogPage"/>
155+
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteConfigurableProduct">
156+
<argument name="product" value="_defaultProduct"/>
157+
</actionGroup>
158+
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetSearch"/>
159+
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
160+
<deleteData stepKey="deleteAttribute" createDataKey="createConfigProductAttribute"/>
161+
<actionGroup ref="logout" stepKey="logout"/>
162+
</after>
163+
<!-- Create configurable product from downloadable product page-->
164+
<comment userInput="Create configurable product" stepKey="commentCreateProduct"/>
165+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
166+
<!-- Open Dropdown and select downloadable product option -->
167+
<comment stepKey="beforeOpenProductFillForm" userInput="Selecting Product from the Add Product Dropdown"/>
168+
<actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="openProductFillForm">
169+
<argument name="productType" value="downloadable"/>
170+
</actionGroup>
171+
<scrollTo selector="{{AdminProductDownloadableSection.sectionHeader}}" stepKey="scrollToDownloadableInfo" />
172+
<uncheckOption selector="{{AdminProductDownloadableSection.isDownloadableProduct}}" stepKey="checkIsDownloadable"/>
173+
<!-- Fill form for Downloadable Product Type -->
174+
<comment stepKey="beforeFillProductForm" userInput="Filling Product Form"/>
175+
<actionGroup ref="fillMainProductForm" stepKey="fillProductForm">
176+
<argument name="product" value="_defaultProduct"/>
177+
</actionGroup>
178+
<actionGroup ref="SetProductUrlKey" stepKey="setProductUrl">
179+
<argument name="product" value="_defaultProduct"/>
180+
</actionGroup>
181+
<comment before="createConfiguration" stepKey="beforeCreateConfiguration" userInput="Adding Configuration to Product"/>
182+
<actionGroup ref="generateConfigurationsByAttributeCode" stepKey="createConfiguration">
183+
<argument name="attributeCode" value="$$createConfigProductAttribute.attribute_code$$"/>
184+
</actionGroup>
185+
<actionGroup ref="saveConfiguredProduct" stepKey="saveProductForm"/>
186+
<!-- Check that product was added with implicit type change -->
187+
<comment stepKey="beforeVerify" userInput="Verify Product Type Assigned Correctly"/>
188+
<actionGroup ref="GoToProductCatalogPage" stepKey="goToProductCatalogPage"/>
189+
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetSearch"/>
190+
<actionGroup ref="filterProductGridByName" stepKey="searchForProduct">
191+
<argument name="product" value="_defaultProduct"/>
192+
</actionGroup>
193+
<see selector="{{AdminProductGridSection.productGridCell('2', 'Type')}}" userInput="Configurable Product" stepKey="seeProductTypeInGrid"/>
194+
<actionGroup ref="AssertProductInStorefrontProductPage" stepKey="assertProductInStorefrontProductPage">
195+
<argument name="product" value="_defaultProduct"/>
196+
</actionGroup>
197+
<actionGroup ref="VerifyOptionInProductStorefront" stepKey="verifyConfigurableOption">
198+
<argument name="attributeCode" value="$createConfigProductAttribute.default_frontend_label$"/>
199+
<argument name="optionName" value="$createConfigProductAttributeOption1.option[store_labels][1][label]$"/>
200+
</actionGroup>
201+
</test>
86202
</tests>

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetAvailablePaymentMethodsTest.php

Lines changed: 44 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77

88
namespace Magento\GraphQl\Quote\Customer;
99

10+
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
1011
use Magento\Integration\Api\CustomerTokenServiceInterface;
11-
use Magento\Quote\Model\QuoteFactory;
12-
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
13-
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
1412
use Magento\TestFramework\Helper\Bootstrap;
1513
use Magento\TestFramework\TestCase\GraphQlAbstract;
1614

@@ -25,75 +23,70 @@ class GetAvailablePaymentMethodsTest extends GraphQlAbstract
2523
private $customerTokenService;
2624

2725
/**
28-
* @var QuoteResource
26+
* @var GetMaskedQuoteIdByReservedOrderId
2927
*/
30-
private $quoteResource;
31-
32-
/**
33-
* @var QuoteFactory
34-
*/
35-
private $quoteFactory;
36-
37-
/**
38-
* @var QuoteIdToMaskedQuoteIdInterface
39-
*/
40-
private $quoteIdToMaskedId;
28+
private $getMaskedQuoteIdByReservedOrderId;
4129

4230
/**
4331
* @inheritdoc
4432
*/
4533
protected function setUp()
4634
{
4735
$objectManager = Bootstrap::getObjectManager();
48-
$this->quoteResource = $objectManager->get(QuoteResource::class);
49-
$this->quoteFactory = $objectManager->get(QuoteFactory::class);
50-
$this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class);
36+
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
5137
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
5238
}
5339

5440
/**
55-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
41+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
42+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
43+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
44+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
45+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
5646
*/
57-
public function testGetCartWithPaymentMethods()
47+
public function testGetAvailablePaymentMethods()
5848
{
59-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items');
49+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
6050
$query = $this->getQuery($maskedQuoteId);
6151
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
6252

6353
self::assertArrayHasKey('cart', $response);
54+
self::assertArrayHasKey('available_payment_methods', $response['cart']);
55+
6456
self::assertEquals('checkmo', $response['cart']['available_payment_methods'][0]['code']);
6557
self::assertEquals('Check / Money order', $response['cart']['available_payment_methods'][0]['title']);
66-
self::assertGreaterThan(
67-
0,
68-
count($response['cart']['available_payment_methods']),
69-
'There are no available payment methods for customer cart!'
70-
);
7158
}
7259

7360
/**
61+
* _security
7462
* @magentoApiDataFixture Magento/Customer/_files/customer.php
75-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
63+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
64+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
65+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
66+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
7667
*/
77-
public function testGetPaymentMethodsFromGuestCart()
68+
public function testGetAvailablePaymentMethodsFromGuestCart()
7869
{
79-
$guestQuoteMaskedId = $this->getMaskedQuoteIdByReservedOrderId(
80-
'test_order_with_virtual_product_without_address'
81-
);
82-
$query = $this->getQuery($guestQuoteMaskedId);
70+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
71+
$query = $this->getQuery($maskedQuoteId);
8372

8473
$this->expectExceptionMessage(
85-
"The current user cannot perform operations on cart \"$guestQuoteMaskedId\""
74+
"The current user cannot perform operations on cart \"$maskedQuoteId\""
8675
);
8776
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
8877
}
8978

9079
/**
80+
* _security
9181
* @magentoApiDataFixture Magento/Customer/_files/three_customers.php
92-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
82+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
83+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
84+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
85+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
9386
*/
94-
public function testGetPaymentMethodsFromAnotherCustomerCart()
87+
public function testGetAvailablePaymentMethodsFromAnotherCustomerCart()
9588
{
96-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items');
89+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
9790
$query = $this->getQuery($maskedQuoteId);
9891

9992
$this->expectExceptionMessage(
@@ -103,24 +96,31 @@ public function testGetPaymentMethodsFromAnotherCustomerCart()
10396
}
10497

10598
/**
106-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
107-
* @magentoApiDataFixture Magento/Payment/_files/disable_all_active_payment_methods.php
99+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
100+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
101+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
102+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
103+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
104+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/disable_all_active_payment_methods.php
108105
*/
109-
public function testGetPaymentMethodsIfPaymentsAreNotSet()
106+
public function testGetAvailablePaymentMethodsIfPaymentsAreNotPresent()
110107
{
111-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items');
108+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
112109
$query = $this->getQuery($maskedQuoteId);
113110
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
114111

115-
self::assertEquals(0, count($response['cart']['available_payment_methods']));
112+
self::assertArrayHasKey('cart', $response);
113+
self::assertArrayHasKey('available_payment_methods', $response['cart']);
114+
self::assertEmpty($response['cart']['available_payment_methods']);
116115
}
117116

118117
/**
119118
* @magentoApiDataFixture Magento/Customer/_files/customer.php
119+
*
120120
* @expectedException \Exception
121121
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
122122
*/
123-
public function testGetPaymentMethodsOfNonExistentCart()
123+
public function testGetAvailablePaymentMethodsOfNonExistentCart()
124124
{
125125
$maskedQuoteId = 'non_existent_masked_id';
126126
$query = $this->getQuery($maskedQuoteId);
@@ -132,9 +132,8 @@ public function testGetPaymentMethodsOfNonExistentCart()
132132
* @param string $maskedQuoteId
133133
* @return string
134134
*/
135-
private function getQuery(
136-
string $maskedQuoteId
137-
): string {
135+
private function getQuery(string $maskedQuoteId): string
136+
{
138137
return <<<QUERY
139138
{
140139
cart(cart_id: "$maskedQuoteId") {
@@ -158,16 +157,4 @@ private function getHeaderMap(string $username = 'customer@example.com', string
158157
$headerMap = ['Authorization' => 'Bearer ' . $customerToken];
159158
return $headerMap;
160159
}
161-
162-
/**
163-
* @param string $reservedOrderId
164-
* @return string
165-
*/
166-
private function getMaskedQuoteIdByReservedOrderId(string $reservedOrderId): string
167-
{
168-
$quote = $this->quoteFactory->create();
169-
$this->quoteResource->load($quote, $reservedOrderId, 'reserved_order_id');
170-
171-
return $this->quoteIdToMaskedId->execute((int)$quote->getId());
172-
}
173160
}

0 commit comments

Comments
 (0)