You are here

public function ShippingOrderManagerTest::testHasShipments in Commerce Shipping 8.2

@covers ::hasShipments

File

tests/src/Kernel/ShippingOrderManagerTest.php, line 185

Class

ShippingOrderManagerTest
Tests the shipping order manager.

Namespace

Drupal\Tests\commerce_shipping\Kernel

Code

public function testHasShipments() {
  $this
    ->assertFalse($this->shippingOrderManager
    ->hasShipments($this->nonShippableOrder));
  $this
    ->assertFalse($this->shippingOrderManager
    ->hasShipments($this->shippableOrder));
  $shipping_profile = Profile::create([
    'type' => 'customer',
    'address' => [
      'country_code' => 'FR',
    ],
  ]);
  $shipping_profile
    ->save();
  $shipments = $this->shippingOrderManager
    ->pack($this->shippableOrder, $shipping_profile);
  $this->shippableOrder
    ->set('shipments', $shipments);
  $this
    ->assertTrue($this->shippingOrderManager
    ->hasShipments($this->shippableOrder));
  $this->shippableOrder
    ->set('shipments', []);
  $this
    ->assertFalse($this->shippingOrderManager
    ->hasShipments($this->shippableOrder));
}