13
13
use Magento \Sales \Api \Data \OrderInterfaceFactory ;
14
14
use Magento \Sales \Block \Adminhtml \Order \Totals \Tax ;
15
15
use Magento \Sales \Model \Order ;
16
+ use Magento \Tax \Model \ResourceModel \Sales \Order \Tax \Collection as TaxCollection ;
17
+ use Magento \Tax \Model \Sales \Order \Tax as SalesTax ;
16
18
use Magento \TestFramework \Helper \Bootstrap ;
17
19
use PHPUnit \Framework \TestCase ;
18
20
@@ -51,8 +53,9 @@ protected function setUp(): void
51
53
*
52
54
* @magentoConfigFixture default_store tax/sales_display/subtotal 2
53
55
* @magentoConfigFixture default_store tax/sales_display/shipping 2
56
+ * @magentoConfigFixture default_store tax/sales_display/full_summary 1
54
57
*
55
- * @magentoDataFixture Magento/Sales /_files/order .php
58
+ * @magentoDataFixture Magento/Tax /_files/order_with_tax .php
56
59
*
57
60
* @return void
58
61
*/
@@ -68,6 +71,11 @@ public function testTotalsInclTax(): void
68
71
$ blockTotals ->setChild ('child_tax_block ' , $ blockTax );
69
72
$ blockTax ->initTotals ();
70
73
74
+ /** @var TaxCollection $taxCollection */
75
+ $ taxCollection = $ this ->om ->get (TaxCollection::class);
76
+ $ tax = $ taxCollection ->loadByOrder ($ order )->getItems ();
77
+ $ tax = array_pop ($ tax );
78
+ $ this ->assertTaxRate ($ blockTax ->toHtml (), $ tax );
71
79
$ this ->assertSubtotal ($ blockTotals ->toHtml (), (float ) $ order ->getSubtotalInclTax ());
72
80
$ this ->assertShipping ($ blockTotals ->toHtml (), (float ) $ order ->getShippingInclTax ());
73
81
}
@@ -132,6 +140,21 @@ private function assertShipping(string $blockTotalsHtml, float $amount): void
132
140
);
133
141
}
134
142
143
+ /**
144
+ * Check if tax rate present in block.
145
+ *
146
+ * @param string $blockTaxHtml
147
+ * @param SalesTax $tax
148
+ * @return void
149
+ */
150
+ private function assertTaxRate (string $ blockTaxHtml , SalesTax $ tax )
151
+ {
152
+ $ this ->assertStringContainsString (
153
+ $ tax ->getTitle () . ' ( ' . (int )$ tax ->getAmount () . '%) ' ,
154
+ $ blockTaxHtml
155
+ );
156
+ }
157
+
135
158
/**
136
159
* Prepare order for test.
137
160
*
0 commit comments