public function TaxRatePercentageTest::testValid in Commerce Core 8.2
@covers ::__construct @covers ::getNumber @covers ::getStartDate @covers ::getEndDate @covers ::toArray
File
- modules/
tax/ tests/ src/ Kernel/ TaxRatePercentageTest.php, line 46
Class
- TaxRatePercentageTest
- @coversDefaultClass \Drupal\commerce_tax\TaxRatePercentage @group commerce
Namespace
Drupal\Tests\commerce_tax\KernelCode
public function testValid() {
// Can't use a unit test because DrupalDateTime objects use \Drupal.
$definition = [
'number' => '0.23',
'start_date' => '2012-01-01',
];
$percentage = new TaxRatePercentage($definition);
$this
->assertEquals($definition['number'], $percentage
->getNumber());
$this
->assertEquals(new DrupalDateTime($definition['start_date'], 'UTC'), $percentage
->getStartDate());
$this
->assertNull($percentage
->getEndDate());
$definition['end_date'] = '2012-12-31';
$percentage = new TaxRatePercentage($definition);
$this
->assertEquals(new DrupalDateTime($definition['end_date'], 'UTC'), $percentage
->getEndDate());
$this
->assertEquals($definition, $percentage
->toArray());
}