9
9
10
10
use Magento \TestFramework \Helper \Bootstrap ;
11
11
use Magento \TestFramework \Quote \Model \GetQuoteByReservedOrderId ;
12
+ use Magento \Catalog \Api \ProductRepositoryInterface ;
13
+ use Magento \Quote \Api \Data \CartItemInterfaceFactory ;
12
14
use Magento \Catalog \Api \TierPriceStorageInterface ;
13
15
use Magento \Catalog \Api \Data \TierPriceInterfaceFactory ;
16
+
14
17
use PHPUnit \Framework \TestCase ;
15
18
16
19
/**
@@ -23,6 +26,12 @@ class UpdateQuoteTest extends TestCase
23
26
*/
24
27
private $ getQuoteByReservedOrderId ;
25
28
29
+ /** @var ProductRepositoryInterface */
30
+ private $ productRepository ;
31
+
32
+ /** @var CartItemInterfaceFactory */
33
+ private $ itemFactory ;
34
+
26
35
/**
27
36
* @var TierPriceStorageInterface
28
37
*/
@@ -44,37 +53,49 @@ protected function setUp(): void
44
53
$ this ->getQuoteByReservedOrderId = $ objectManager ->get (GetQuoteByReservedOrderId::class);
45
54
$ this ->tierPriceStorage = $ objectManager ->get (TierPriceStorageInterface::class);
46
55
$ this ->tierPriceFactory = $ objectManager ->get (TierPriceInterfaceFactory::class);
56
+ $ this ->itemFactory = $ objectManager ->get (CartItemInterfaceFactory::class);
57
+ $ this ->productRepository = $ objectManager ->get (ProductRepositoryInterface::class);
47
58
}
48
59
49
60
/**
50
61
* Test to update the column trigger_recollect is 1 from quote table.
51
62
*
52
- * @magentoDataFixture Magento/Checkout /_files/quote_with_simple_product_saved .php
53
- * @magentoDbIsolation disabled
63
+ * @magentoDataFixture Magento/Sales /_files/quote .php
64
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
54
65
* @return void
55
66
*/
56
67
public function testUpdateQuoteRecollectAfterChangeProductPrice (): void
57
68
{
58
- $ quoteId = 'test_order_with_simple_product_without_address ' ;
69
+ $ quoteId = 'test01 ' ;
70
+ $ productSku = 'simple ' ;
59
71
$ quote = $ this ->getQuoteByReservedOrderId ->execute ($ quoteId );
60
- $ this ->assertNotNull ($ quote );
61
- $ this ->assertFalse ((bool )$ quote ->getTriggerRecollect ());
62
- $ this ->assertNotEmpty ($ quote ->getItems ());
63
- $ quoteItem = current ($ quote ->getItems ());
64
- $ product = $ quoteItem ->getProduct ();
72
+
73
+ $ quoteItem = $ this ->itemFactory ->create ();
74
+
75
+ $ product = $ this ->productRepository ->get ($ productSku );
76
+
77
+ $ quoteItem ->setProduct ($ product );
65
78
$ quoteItem ->setProductId ($ product ->getRowId ());
79
+
80
+ $ quote ->addItem ($ quoteItem );
81
+ $ quote ->setTriggerRecollect (0 );
66
82
$ quote ->save ();
67
83
84
+ $ this ->assertNotNull ($ quote );
85
+ $ this ->assertFalse ((bool )$ quote ->getTriggerRecollect ());
86
+
68
87
$ tierPrice = $ this ->tierPriceFactory ->create ();
69
88
$ tierPrice ->setPrice ($ product ->getPrice ());
70
89
$ tierPrice ->setPriceType ('fixed ' );
71
90
$ tierPrice ->setWebsiteId (0 );
72
91
$ tierPrice ->setSku ($ product ->getSku ());
73
92
$ tierPrice ->setCustomerGroup ('ALL GROUPS ' );
74
93
$ tierPrice ->setQuantity (1 );
94
+
75
95
$ this ->tierPriceStorage ->update ([$ tierPrice ]);
76
96
77
97
$ quote = $ this ->getQuoteByReservedOrderId ->execute ($ quoteId );
98
+
78
99
$ this ->assertNotEmpty ($ quote ->getTriggerRecollect ());
79
100
$ this ->assertTrue ((bool )$ quote ->getTriggerRecollect ());
80
101
}
0 commit comments