NorwegianVatTest.php in Commerce Core 8.2        
                          
                  
                        
  
  
  
  
  
File
  modules/tax/tests/src/Kernel/Plugin/Commerce/TaxType/NorwegianVatTest.php
  
    View source  
  <?php
namespace Drupal\Tests\commerce_tax\Kernel\Plugin\Commerce\TaxType;
use Drupal\commerce_tax\Entity\TaxType;
class NorwegianVatTest extends EuropeanUnionVatTest {
  
  protected function setUp() : void {
    parent::setUp();
    $this->taxType = TaxType::create([
      'id' => 'norwegian_vat',
      'label' => 'Norwegian VAT',
      'plugin' => 'norwegian_vat',
      'configuration' => [
        'display_inclusive' => TRUE,
      ],
      
      'status' => FALSE,
    ]);
    $this->taxType
      ->save();
  }
  
  public function testApplication() {
    $plugin = $this->taxType
      ->getPlugin();
    
    $order = $this
      ->buildOrder('NO', 'NO');
    $this
      ->assertTrue($plugin
      ->applies($order));
    $plugin
      ->apply($order);
    $adjustments = $order
      ->collectAdjustments();
    $adjustment = reset($adjustments);
    $this
      ->assertCount(1, $adjustments);
    $this
      ->assertEquals('norwegian_vat|no|standard', $adjustment
      ->getSourceId());
    
    $order = $this
      ->buildOrder('PL', 'NO');
    $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('no', $zones);
  }
}