-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy pathOrderCreateSingleStockModeConfigurableProductTest.php
executable file
·130 lines (124 loc) · 5.12 KB
/
OrderCreateSingleStockModeConfigurableProductTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\InventorySales\Test\Api;
/**
* Web Api order create in single stock mode configurable product tests.
*/
class OrderCreateSingleStockModeConfigurableProductTest extends OrderPlacementBase
{
/**
* Create order with configurable product - registered customer, single stock mode, default website.
*
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
*
* @see https://app.hiptest.com/projects/69435/test-plan/folders/915538/scenarios/1868245
*
* @return void
*/
public function testCustomerPlaceOrderDefaultWebsite(): void
{
$this->_markTestAsRestOnly();
$this->getCustomerToken('customer@example.com', 'password');
$this->createCustomerCart();
$this->addConfigurableProduct('configurable');
$this->estimateShippingCosts();
$this->setShippingAndBillingInformation();
$orderId = $this->submitPaymentInformation();
$this->verifyCreatedOrder($orderId);
$this->cancelOrder($orderId);
}
/**
* Create order with configurable product - registered customer, single stock mode, additional website.
*
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
*
* @return void
*/
public function testCustomerPlaceOrderAdditionalWebsite(): void
{
$this->_markTestAsRestOnly();
$websiteCode = 'eu_website';
$products = ['configurable', 'simple_10'];
$this->assignCustomerToCustomWebsite('customer@example.com', $websiteCode);
$this->assignProductsToWebsite($products, $websiteCode);
$this->setStoreView('store_for_eu_website');
$this->getCustomerToken('customer@example.com', 'password');
$this->createCustomerCart();
$this->addConfigurableProduct('configurable');
$this->estimateShippingCosts();
$this->setShippingAndBillingInformation();
$orderId = $this->submitPaymentInformation();
$this->verifyCreatedOrder($orderId);
$this->cancelOrder($orderId);
}
/**
* Create order with configurable product - guest customer, single stock mode, default website.
*
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
*
* @return void
*/
public function testGuestPlaceOrderDefaultWebsite(): void
{
$this->_markTestAsRestOnly();
$this->createCustomerCart();
$this->addConfigurableProduct('configurable');
$this->estimateShippingCosts();
$this->setShippingAndBillingInformation();
$orderId = $this->submitPaymentInformation();
$this->verifyCreatedOrder($orderId);
$this->cancelOrder($orderId);
}
/**
* Create order with configurable product - guest customer, single stock mode, additional website.
*
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
*
* @return void
*/
public function testGuestPlaceOrderAdditionalWebsite(): void
{
$this->_markTestAsRestOnly();
$websiteCode = 'eu_website';
$products = ['configurable', 'simple_10'];
$this->assignProductsToWebsite($products, $websiteCode);
$this->setStoreView('store_for_eu_website');
$this->createCustomerCart();
$this->addConfigurableProduct('configurable');
$this->estimateShippingCosts();
$this->setShippingAndBillingInformation();
$orderId = $this->submitPaymentInformation();
$this->verifyCreatedOrder($orderId);
$this->cancelOrder($orderId);
}
/**
* Verify created order is correct.
*
* @param int $orderId
* @return void
*/
private function verifyCreatedOrder(int $orderId): void
{
$order = $this->getOrder($orderId);
$this->assertGreaterThan(0, $order['increment_id']);
$this->assertEquals('customer@example.com', $order['customer_email']);
$this->assertEquals('simple_10', $order['items'][0]['sku']);
$this->assertEquals('Configurable Product', $order['items'][0]['name']);
$this->assertEquals('configurable', $order['items'][0]['product_type']);
$this->assertEquals(10, $order['items'][0]['price']);
$this->assertEquals(1, $order['items'][0]['qty_ordered']);
$this->assertEquals('simple_10', $order['items'][1]['sku']);
$this->assertEquals('Configurable OptionOption 1', $order['items'][1]['name']);
$this->assertEquals('simple', $order['items'][1]['product_type']);
$this->assertEquals(10, $order['items'][1]['price']);
$this->assertEquals(1, $order['items'][1]['qty_ordered']);
}
}