You are here

protected function StoredTaxTest::assertTaxLineCorrect in Ubercart 8.4

Complex assert to check various parts of the tax line item.

1 call to StoredTaxTest::assertTaxLineCorrect()
StoredTaxTest::testTaxDisplay in uc_tax/tests/src/Functional/StoredTaxTest.php
Tests display of taxes.

File

uc_tax/tests/src/Functional/StoredTaxTest.php, line 151

Class

StoredTaxTest
Tests stored taxes.

Namespace

Drupal\Tests\uc_tax\Functional

Code

protected function assertTaxLineCorrect($line, $rate, $when) {

  /** @var \Drupal\Tests\WebAssert $assert */
  $assert = $this
    ->assertSession();
  $this
    ->assertTrue($line, 'The tax line item was saved to the order ' . $when);
  $this
    ->assertEquals(number_format($rate * $this->product->price->value, 2), number_format($line['amount'], 2), 'Stored tax line item has the correct amount ' . $when);

  // Check for the tax line item ID.
  $assert
    ->hiddenFieldValueEquals('line_items[' . $line['line_item_id'] . '][li_id]', $line['line_item_id']);
  $assert
    ->pageTextContains($line['title']);
  $this
    ->assertTrue(TRUE, 'Found the tax title ' . $when);
  $assert
    ->pageTextContains(uc_currency_format($line['amount']));
  $this
    ->assertTrue(TRUE, 'Tax display has the correct amount ' . $when);
}