public function OrderWorkflowTest::testOrderFulfillment in Commerce Shipping 8.2
Tests the order fulfillment.
File
- tests/
src/ Kernel/ OrderWorkflowTest.php, line 97
Class
- OrderWorkflowTest
- Tests the interaction between order and shipping workflows.
Namespace
Drupal\Tests\commerce_shipping\KernelCode
public function testOrderFulfillment() {
$order_type = OrderType::load($this->order
->bundle());
$order_type
->setWorkflowId('order_fulfillment');
$order_type
->save();
$transitions = $this->order
->getState()
->getTransitions();
$this->order
->getState()
->applyTransition($transitions['place']);
$this->order
->save();
$shipment = $this
->reloadEntity($this->shipment);
$this
->assertEquals('ready', $shipment
->getState()->value, 'The shipment has been correctly finalized.');
$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);
}