public function OrderWorkflowTest::testOrderValidation in Commerce Shipping 8.2
Tests the order validation.
File
- tests/
src/ Kernel/ OrderWorkflowTest.php, line 119  
Class
- OrderWorkflowTest
 - Tests the interaction between order and shipping workflows.
 
Namespace
Drupal\Tests\commerce_shipping\KernelCode
public function testOrderValidation() {
  $order_type = OrderType::load($this->order
    ->bundle());
  $order_type
    ->setWorkflowId('order_fulfillment_validation');
  $order_type
    ->save();
  $transitions = $this->order
    ->getState()
    ->getTransitions();
  $this->order
    ->getState()
    ->applyTransition($transitions['place']);
  $this->order
    ->save();
  $shipment = $this
    ->reloadEntity($this->shipment);
  $this
    ->assertEquals('draft', $shipment
    ->getState()->value);
  $transitions = $this->order
    ->getState()
    ->getTransitions();
  $this->order
    ->getState()
    ->applyTransition($transitions['validate']);
  $this->order
    ->save();
  $shipment = $this
    ->reloadEntity($this->shipment);
  $this
    ->assertEquals('ready', $shipment
    ->getState()->value);
  $transitions = $this->order
    ->getState()
    ->getTransitions();
  $this->order
    ->getState()
    ->applyTransition($transitions['fulfill']);
  $this->order
    ->save();
  $shipment = $this
    ->reloadEntity($this->shipment);
  $this
    ->assertEquals('shipped', $shipment
    ->getState()->value);
}