Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertTaxRuleIsNotApplied.php
Go to the documentation of this file.
1 <?php
8 
13 {
19  protected function assert()
20  {
21  $errorMessages = [];
22 
23  // Preparing data to compare
24  $expectedGrandTotal = $this->productSimple->getPrice() + $this->shipping['price'];
25  $expectedGrandTotal = number_format($expectedGrandTotal, 2);
26  $actualGrandTotal = $this->checkoutCart->getTotalsBlock()->getGrandTotal();
27 
28  if ($this->checkoutCart->getTotalsBlock()->isTaxVisible()) {
29  $errorMessages[] = 'Tax Rule \'' . $this->taxRuleCode . '\' present in shopping cart.';
30  }
31  if ($expectedGrandTotal !== $actualGrandTotal) {
32  $errorMessages[] = 'Grand Total is not correct.'
33  . "\nExpected: " . $expectedGrandTotal
34  . "\nActual: " . $actualGrandTotal;
35  }
36 
37  \PHPUnit\Framework\Assert::assertTrue(empty($errorMessages), implode(";\n", $errorMessages));
38  }
39 
45  public function toString()
46  {
47  return "Tax rule was not applied on product in shopping cart.";
48  }
49 }