public function OrderItemTypeTest::testDelete in Commerce Core 8.2
Tests deleting an order item type.
File
- modules/
order/ tests/ src/ Functional/ OrderItemTypeTest.php, line 88
Class
- OrderItemTypeTest
- Tests the order item type UI.
Namespace
Drupal\Tests\commerce_order\FunctionalCode
public function testDelete() {
/** @var \Drupal\commerce_order\Entity\OrderItemTypeInterface $order_item_type */
$order_item_type = $this
->createEntity('commerce_order_item_type', [
'id' => strtolower($this
->randomMachineName(8)),
'label' => $this
->randomMachineName(16),
'purchasableEntityType' => 'commerce_product_variation',
'orderType' => 'default',
]);
// Confirm that the delete page is not available when the type is locked.
$order_item_type
->lock();
$order_item_type
->save();
$this
->drupalGet($order_item_type
->toUrl('delete-form'));
$this
->assertSession()
->statusCodeEquals('403');
// Unlock the type, confirm that deletion works.
$order_item_type
->unlock();
$order_item_type
->save();
$this
->drupalGet($order_item_type
->toUrl('delete-form'));
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains(t('This action cannot be undone.'));
$this
->submitForm([], t('Delete'));
$order_item_type_exists = (bool) OrderItemType::load($order_item_type
->id());
$this
->assertEmpty($order_item_type_exists);
}