public function EuropeanUnionVatTest::testApplication in Commerce Core 8.2
@covers ::applies @covers ::apply
3 methods override EuropeanUnionVatTest::testApplication()
- NorwegianVatTest::testApplication in modules/
tax/ tests/ src/ Kernel/ Plugin/ Commerce/ TaxType/ NorwegianVatTest.php - @covers ::applies @covers ::apply
- SwissVatTest::testApplication in modules/
tax/ tests/ src/ Kernel/ Plugin/ Commerce/ TaxType/ SwissVatTest.php - @covers ::applies @covers ::apply
- UnitedKingdomVatTest::testApplication in modules/
tax/ tests/ src/ Kernel/ Plugin/ Commerce/ TaxType/ UnitedKingdomVatTest.php - @covers ::applies @covers ::apply
File
- modules/
tax/ tests/ src/ Kernel/ Plugin/ Commerce/ TaxType/ EuropeanUnionVatTest.php, line 91
Class
- EuropeanUnionVatTest
- @coversDefaultClass \Drupal\commerce_tax\Plugin\Commerce\TaxType\EuropeanUnionVat @group commerce
Namespace
Drupal\Tests\commerce_tax\Kernel\Plugin\Commerce\TaxTypeCode
public function testApplication() {
$plugin = $this->taxType
->getPlugin();
// German customer, French store, VAT number provided.
$order = $this
->buildOrder('DE', 'FR', 'DE123456789');
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$adjustment = reset($adjustments);
$this
->assertCount(1, $adjustments);
$this
->assertEquals('european_union_vat|ic|zero', $adjustment
->getSourceId());
// French customer, French store, VAT number provided.
$order = $this
->buildOrder('FR', 'FR', 'FR00123456789');
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$adjustment = reset($adjustments);
$this
->assertCount(1, $adjustments);
$this
->assertEquals('european_union_vat|fr|standard', $adjustment
->getSourceId());
// German customer, French store, physical product.
$order = $this
->buildOrder('DE', 'FR');
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$adjustment = reset($adjustments);
$this
->assertCount(1, $adjustments);
$this
->assertEquals('european_union_vat|fr|standard', $adjustment
->getSourceId());
// GB customer, French store, no VAT.
$order = $this
->buildOrder('GB', 'FR');
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$this
->assertCount(0, $adjustments);
// German customer, French store registered for German VAT, physical product.
$order = $this
->buildOrder('DE', 'FR', '', [
'DE',
]);
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$adjustment = reset($adjustments);
$this
->assertCount(1, $adjustments);
$this
->assertEquals('european_union_vat|de|standard', $adjustment
->getSourceId());
// German customer, French store, digital product before Jan 1st 2015.
$order = $this
->buildOrder('DE', 'FR', '', [], TRUE);
$order
->setPlacedTime(mktime(1, 1, 1, 1, 1, 2014));
$order
->save();
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$adjustment = reset($adjustments);
$this
->assertCount(1, $adjustments);
$this
->assertEquals('european_union_vat|fr|standard', $adjustment
->getSourceId());
// German customer, French store, digital product.
$order = $this
->buildOrder('DE', 'FR', '', [], TRUE);
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$adjustment = reset($adjustments);
$this
->assertCount(1, $adjustments);
$this
->assertEquals('european_union_vat|de|standard', $adjustment
->getSourceId());
// German customer, US store registered in FR, digital product.
$order = $this
->buildOrder('DE', 'US', '', [
'FR',
], TRUE);
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$adjustment = reset($adjustments);
$this
->assertCount(1, $adjustments);
$this
->assertEquals('european_union_vat|de|standard', $adjustment
->getSourceId());
// German customer with VAT number, US store registered in FR, digital product.
$order = $this
->buildOrder('DE', 'US', 'DE123456789', [
'FR',
], TRUE);
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$adjustments = $order
->collectAdjustments();
$adjustment = reset($adjustments);
$this
->assertCount(1, $adjustments);
$this
->assertEquals('european_union_vat|ic|zero', $adjustment
->getSourceId());
// Serbian customer, French store, physical product.
$order = $this
->buildOrder('RS', 'FR');
$this
->assertTrue($plugin
->applies($order));
$plugin
->apply($order);
$this
->assertCount(0, $order
->collectAdjustments());
// French customer, Serbian store, physical product.
$order = $this
->buildOrder('FR', 'RS');
$this
->assertFalse($plugin
->applies($order));
}