You are here

public function IntervalTest::testGetters in Commerce Core 8.2

Tests the methods for getting the number/unit in various formats.

::covers getNumber ::covers getUnit ::covers __toString ::covers toArray.

File

tests/src/Kernel/IntervalTest.php, line 52

Class

IntervalTest
Tests the Interval class.

Namespace

Drupal\Tests\commerce\Kernel

Code

public function testGetters() {
  $interval = new Interval('1', 'month');
  $this
    ->assertEquals('1', $interval
    ->getNumber());
  $this
    ->assertEquals('month', $interval
    ->getUnit());
  $this
    ->assertEquals('1 month', $interval
    ->__toString());
  $this
    ->assertEquals([
    'number' => '1',
    'unit' => 'month',
  ], $interval
    ->toArray());
}