TaxRateUiTest.php in Ubercart 8.4
File
uc_tax/tests/src/Functional/TaxRateUiTest.php
View source
<?php
namespace Drupal\Tests\uc_tax\Functional;
class TaxRateUiTest extends TaxTestBase {
public function testTaxUi() {
$assert = $this
->assertSession();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/store/config');
$assert
->linkByHrefExists('admin/store/config/tax');
$assert
->pageTextContains('Configure tax rates and rules.');
$this
->clickLink('Tax rates');
$assert
->addressEquals('admin/store/config/tax');
$assert
->pageTextContains('No tax rates have been configured yet.');
$rate = [
'label' => $this
->randomMachineName(8),
'settings[rate]' => 20,
'settings[jurisdiction]' => 'Uberland',
'shippable' => 0,
'product_types[product]' => 1,
'product_types[blank-line]' => 1,
'line_item_types[generic]' => 1,
'line_item_types[tax]' => 1,
'display_include' => 1,
'inclusion_text' => ' incl. tax',
];
$tax_rate = $this
->createTaxRate('percentage_rate', $rate);
$this
->drupalGet('admin/store/config/tax');
$assert
->pageTextContains($tax_rate
->label());
$assert
->pageTextContains($tax_rate
->getRate() . '%');
$assert
->pageTextContains('Any product');
$assert
->pageTextContains('product, blank-line');
$assert
->pageTextContains('generic, tax');
$this
->drupalGet('admin/store/config/tax');
$this
->clickLink('Clone');
$assert
->addressEquals('admin/store/config/tax');
$assert
->pageTextContains('Tax rate ' . $tax_rate
->label() . ' was cloned.');
$this
->submitForm([
'entities[' . $tax_rate
->id() . '_clone][weight]' => -10,
], 'Save configuration');
$assert
->addressEquals('admin/store/config/tax');
$this
->clickLink('Delete');
$assert
->addressEquals('admin/store/config/tax/' . $tax_rate
->id() . '_clone/delete');
$assert
->pageTextContains('Are you sure you want to delete Copy of ' . $tax_rate
->label() . '?');
$this
->submitForm([], 'Delete tax rate');
$assert
->addressEquals('admin/store/config/tax');
$assert
->pageTextContains('Tax rate Copy of ' . $tax_rate
->label() . ' has been deleted.');
$this
->drupalGet('admin/store/config/tax');
$assert
->pageTextNotContains('Copy of ' . $tax_rate
->label());
$this
->drupalGet('admin/store/config/tax');
$this
->clickLink('Disable');
$assert
->addressEquals('admin/store/config/tax');
$assert
->pageTextContains('The ' . $tax_rate
->label() . ' tax rate has been disabled.');
$this
->clickLink('Enable');
$assert
->addressEquals('admin/store/config/tax');
$assert
->pageTextContains('The ' . $tax_rate
->label() . ' tax rate has been enabled.');
$this
->drupalGet('admin/store/config/tax');
$this
->clickLink('Edit');
$assert
->addressEquals('admin/store/config/tax/' . $tax_rate
->id());
$assert
->pageTextContains('Default tax rate');
$assert
->pageTextContains('Tax rate override field');
$assert
->pageTextContains('Jurisdiction');
$assert
->pageTextContains('Taxed products');
$assert
->pageTextContains('Taxed product types');
$assert
->pageTextContains('Taxed line items');
$assert
->pageTextContains('Tax inclusion text');
$assert
->linkExists('Cancel');
$assert
->linkExists('Delete');
$this
->clickLink('Cancel');
$assert
->addressEquals('admin/store/config/tax');
$this
->submitForm([
'plugin' => 'percentage_rate',
], 'Add tax rate');
$assert
->addressEquals('admin/store/config/tax/add/percentage_rate');
$assert
->pageTextContains('Default tax rate');
$assert
->pageTextContains('Tax rate override field');
$assert
->pageTextContains('Jurisdiction');
$assert
->pageTextContains('Taxed products');
$assert
->pageTextContains('Taxed product types');
$assert
->pageTextContains('Taxed line items');
$assert
->pageTextContains('Tax inclusion text');
$assert
->linkExists('Cancel');
$assert
->linkNotExists('Delete');
}
}
Classes
Name |
Description |
TaxRateUiTest |
Tests the operation of the tax rate configuration user interface. |