8
8
use Magento \Catalog \Model \Product \Type ;
9
9
use Magento \TestFramework \Helper \Bootstrap ;
10
10
11
+ /**
12
+ * Class for testing QuoteManagement model
13
+ */
11
14
class QuoteManagementTest extends \PHPUnit_Framework_TestCase
12
15
{
13
16
/**
14
17
* Create order with product that has child items
15
18
*
19
+ * @magentoAppIsolation enabled
16
20
* @magentoDataFixture Magento/Sales/_files/quote_with_bundle.php
17
21
*/
18
22
public function testSubmit ()
19
23
{
20
- $ this ->markTestSkipped ('MAGETWO-50989 ' );
21
24
/**
22
25
* Preconditions:
23
- * Load quote with Bundle product that has at least to child products
26
+ * Load quote with Bundle product that has at least two child products
24
27
*/
25
28
$ objectManager = Bootstrap::getObjectManager ();
26
29
/** @var \Magento\Quote\Model\Quote $quote */
27
- $ quote = $ objectManager ->create (' \Magento\Quote\Model\Quote ' );
30
+ $ quote = $ objectManager ->create (\Magento \Quote \Model \Quote::class );
28
31
$ quote ->load ('test01 ' , 'reserved_order_id ' );
29
32
30
33
/** Execute SUT */
31
34
/** @var \Magento\Quote\Api\CartManagementInterface $model */
32
- $ model = $ objectManager ->create ('\Magento\Quote\Api\CartManagementInterface ' );
33
- $ order = $ model ->submit ($ quote );
35
+ $ cartManagement = $ objectManager ->create (\Magento \Quote \Api \CartManagementInterface::class);
36
+ /** @var \Magento\Sales\Api\OrderRepositoryInterface $orderRepository */
37
+ $ orderRepository = $ objectManager ->create (\Magento \Sales \Api \OrderRepositoryInterface::class);
38
+ $ orderId = $ cartManagement ->placeOrder ($ quote ->getId ());
39
+ $ order = $ orderRepository ->get ($ orderId );
34
40
35
41
/** Check if SUT caused expected effects */
36
42
$ orderItems = $ order ->getItems ();
@@ -42,4 +48,45 @@ public function testSubmit()
42
48
}
43
49
}
44
50
}
51
+
52
+ /**
53
+ * Create order with product that has child items and one of them was deleted
54
+ *
55
+ * @magentoAppArea adminhtml
56
+ * @magentoAppIsolation enabled
57
+ * @magentoDataFixture Magento/Sales/_files/quote_with_bundle.php
58
+ */
59
+ public function testSubmitWithDeletedItem ()
60
+ {
61
+ /**
62
+ * Preconditions:
63
+ * Load quote with Bundle product that have at least to child products
64
+ */
65
+ $ objectManager = Bootstrap::getObjectManager ();
66
+ /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
67
+ $ productRepository = $ objectManager ->get (\Magento \Catalog \Api \ProductRepositoryInterface::class);
68
+ $ product = $ productRepository ->get ('simple-2 ' );
69
+ $ productRepository ->delete ($ product );
70
+ /** @var \Magento\Quote\Model\Quote $quote */
71
+ $ quote = $ objectManager ->create (\Magento \Quote \Model \Quote::class);
72
+ $ quote ->load ('test01 ' , 'reserved_order_id ' );
73
+
74
+ /** Execute SUT */
75
+ /** @var \Magento\Quote\Api\CartManagementInterface $model */
76
+ $ cartManagement = $ objectManager ->create (\Magento \Quote \Api \CartManagementInterface::class);
77
+ /** @var \Magento\Sales\Api\OrderRepositoryInterface $orderRepository */
78
+ $ orderRepository = $ objectManager ->create (\Magento \Sales \Api \OrderRepositoryInterface::class);
79
+ $ orderId = $ cartManagement ->placeOrder ($ quote ->getId ());
80
+ $ order = $ orderRepository ->get ($ orderId );
81
+
82
+ /** Check if SUT caused expected effects */
83
+ $ orderItems = $ order ->getItems ();
84
+ $ this ->assertCount (2 , $ orderItems );
85
+ foreach ($ orderItems as $ orderItem ) {
86
+ if ($ orderItem ->getProductType () == Type::TYPE_SIMPLE ) {
87
+ $ this ->assertNotEmpty ($ orderItem ->getParentItem (), 'Parent is not set for child product ' );
88
+ $ this ->assertNotEmpty ($ orderItem ->getParentItemId (), 'Parent is not set for child product ' );
89
+ }
90
+ }
91
+ }
45
92
}
0 commit comments