UnitedKingdomVatTest.php in Commerce Core 8.2
File
modules/tax/tests/src/Kernel/Plugin/Commerce/TaxType/UnitedKingdomVatTest.php
View source
<?php
namespace Drupal\Tests\commerce_tax\Kernel\Plugin\Commerce\TaxType;
use Drupal\commerce_tax\Entity\TaxType;
class UnitedKingdomVatTest extends EuropeanUnionVatTest {
protected function setUp() : void {
parent::setUp();
$this->taxType = TaxType::create([
'id' => 'united_kingdom_vat',
'label' => 'UK VAT',
'plugin' => 'united_kingdom_vat',
'configuration' => [
'display_inclusive' => TRUE,
],
'status' => FALSE,
]);
$this->taxType
->save();
}
public function testApplication() {
$plugin = $this->taxType
->getPlugin();
$order = $this
->buildOrder('GB', 'GB');
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$adjustment = reset($adjustments);
$this
->assertCount(1, $adjustments);
$this
->assertEquals('united_kingdom_vat|gb|standard', $adjustment
->getSourceId());
$order = $this
->buildOrder('IM', 'GB');
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$adjustment = reset($adjustments);
$this
->assertCount(1, $adjustments);
$this
->assertEquals('united_kingdom_vat|gb|standard', $adjustment
->getSourceId());
$order = $this
->buildOrder('FR', 'GB');
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$this
->assertCount(0, $adjustments);
}
public function testGetZones() {
$plugin = $this->taxType
->getPlugin();
$zones = $plugin
->getZones();
$this
->assertArrayHasKey('gb', $zones);
}
}