public function ShipmentAdminTest::testShipmentDelete in Commerce Shipping 8.2
Tests deleting a shipment.
File
- tests/
src/ FunctionalJavascript/ ShipmentAdminTest.php, line 557
Class
- ShipmentAdminTest
- Tests the shipment admin UI.
Namespace
Drupal\Tests\commerce_shipping\FunctionalJavascriptCode
public function testShipmentDelete() {
/** @var \Drupal\commerce_shipping\Entity\ShipmentInterface $shipment */
$shipment = $this
->createEntity('commerce_shipment', [
'type' => 'default',
'title' => 'Test shipment',
'order_id' => $this->order
->id(),
'amount' => new Price('10', 'USD'),
'items' => [
new ShipmentItem([
'order_item_id' => 1,
'title' => 'Test shipment item',
'quantity' => 1,
'weight' => new Weight(0, 'g'),
'declared_value' => new Price('1', 'USD'),
]),
],
]);
$this
->drupalGet($this->shipmentUri);
$this
->assertSession()
->pageTextContains($shipment
->label());
$this
->assertSession()
->pageTextContains('$10.00');
$this
->assertSession()
->linkByHrefExists($this->shipmentUri . '/' . $shipment
->id() . '/delete');
$this
->drupalGet($this->shipmentUri . '/' . $shipment
->id() . '/delete');
$this
->getSession()
->getPage()
->pressButton('Delete');
$this
->assertSession()
->addressEquals($this->shipmentUri);
$this
->assertSession()
->pageTextNotContains('$10.00');
\Drupal::entityTypeManager()
->getStorage('commerce_shipment')
->resetCache([
$shipment
->id(),
]);
$shipment = Shipment::load($shipment
->id());
$this
->assertNull($shipment);
}