public function LateOrderProcessorTest::testProcess in Commerce Shipping 8.2
::covers process.
File
- tests/
src/ Kernel/ LateOrderProcessorTest.php, line 89
Class
- LateOrderProcessorTest
- Tests the late order processor.
Namespace
Drupal\Tests\commerce_shipping\KernelCode
public function testProcess() {
/** @var \Drupal\commerce_shipping\Entity\ShipmentInterface[] $shipments */
$shipments = $this->order
->get('shipments')
->referencedEntities();
$shipment = reset($shipments);
$shipment
->setAmount(new Price('3.33', 'USD'));
$shipment
->addAdjustment(new Adjustment([
'type' => 'fee',
'label' => 'Random fee',
'amount' => new Price('2.00', 'USD'),
'locked' => TRUE,
]));
$this->processor
->process($this->order);
/** @var \Drupal\commerce_shipping\Entity\ShipmentInterface $shipment */
$shipment = $this
->reloadEntity($shipment);
// Confirm that modified shipment was saved.
$this
->assertFalse($shipment
->hasTranslationChanges());
// Confirm that the amount and adjustments were transferred to the order.
$adjustments = $this->order
->getAdjustments();
$this
->assertCount(2, $adjustments);
$first_adjustment = reset($adjustments);
$this
->assertEquals('shipping', $first_adjustment
->getType());
$this
->assertEquals(new Price('3.33', 'USD'), $first_adjustment
->getAmount());
$second_adjustment = end($adjustments);
$this
->assertEquals('fee', $second_adjustment
->getType());
$this
->assertEquals(new Price('2.00', 'USD'), $second_adjustment
->getAmount());
// Confirm that locked adjustments are transferred unlocked.
$this
->assertFalse($second_adjustment
->isLocked());
}