You are here

public function PriceTest::testCreateFromValidArray in Commerce Core 8.2

Tests creating a price from a valid array.

::covers __construct.

File

modules/price/tests/src/Unit/PriceTest.php, line 48

Class

PriceTest
Tests the Price class.

Namespace

Drupal\Tests\commerce_price\Unit

Code

public function testCreateFromValidArray() {
  $price = Price::fromArray([
    'number' => '10',
    'currency_code' => 'USD',
  ]);
  $this
    ->assertEquals('10', $price
    ->getNumber());
  $this
    ->assertEquals('USD', $price
    ->getCurrencyCode());
  $this
    ->assertEquals('10 USD', $price
    ->__toString());
  $this
    ->assertEquals([
    'number' => '10',
    'currency_code' => 'USD',
  ], $price
    ->toArray());
}