You are here

public function WishlistPurchaseTest::testCreateFromValidArray in Commerce Wishlist 8.3

Tests creating a purchase from a valid array.

::covers __construct ::covers fromArray().

File

tests/src/Unit/WishlistPurchaseTest.php, line 40

Class

WishlistPurchaseTest
Tests the WishlistPurchase class.

Namespace

Drupal\Tests\commerce_wishlist\Unit

Code

public function testCreateFromValidArray() {
  $time = time();
  $purchase_array = [
    'order_id' => '12',
    'quantity' => '3',
    'purchased' => $time,
  ];
  $purchase = WishlistPurchase::fromArray($purchase_array);
  $this
    ->assertEquals('12', $purchase
    ->getOrderId());
  $this
    ->assertEquals('3', $purchase
    ->getQuantity());
  $this
    ->assertEquals($time, $purchase
    ->getPurchasedTime());
}