public function OrderTypeTest::testDuplicate in Commerce Core 8.2
Tests duplicating an order type.
File
- modules/
order/ tests/ src/ Functional/ OrderTypeTest.php, line 76
Class
- OrderTypeTest
- Tests the order type UI.
Namespace
Drupal\Tests\commerce_order\FunctionalCode
public function testDuplicate() {
$this
->drupalGet('admin/commerce/config/order-types/default/duplicate');
$this
->assertSession()
->fieldValueEquals('label', 'Default');
$edit = [
'label' => 'Default2',
'id' => 'default2',
];
$this
->submitForm($edit, t('Save'));
$this
->assertSession()
->pageTextContains('Saved the Default2 order type.');
// Confirm that the original order type is unchanged.
$order_type = OrderType::load('default');
$this
->assertNotEmpty($order_type);
$this
->assertEquals('Default', $order_type
->label());
$this
->assertEquals('order_default', $order_type
->getNumberPatternId());
// Confirm that the new order type has the expected data.
$order_type = OrderType::load('default2');
$this
->assertNotEmpty($order_type);
$this
->assertEquals('Default2', $order_type
->label());
$this
->assertEquals('order_default', $order_type
->getNumberPatternId());
}