public function OrderTest::testOrderState in Ubercart 8.4
Tests admin and automatic changing of order state and status.
File
- uc_order/
tests/ src/ Functional/ OrderTest.php, line 263
Class
- OrderTest
- Tests for Ubercart orders.
Namespace
Drupal\Tests\uc_order\FunctionalCode
public function testOrderState() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$this
->drupalLogin($this->adminUser);
// Check that the default order state and status is correct.
$this
->drupalGet('admin/store/config/orders');
// Verify that state defaults to correct default status.
$assert
->fieldValueEquals('order_states[in_checkout][default]', 'in_checkout');
$this
->assertEquals('in_checkout', uc_order_state_default('in_checkout'), 'uc_order_state_default() returns correct default status.');
$order = $this
->ucCreateOrder($this->customer);
$this
->assertEquals('in_checkout', $order
->getStateId(), 'Order has correct default state.');
$this
->assertEquals('in_checkout', $order
->getStatusId(), 'Order has correct default status.');
// Create a custom "in checkout" order status with a lower weight.
$this
->drupalGet('admin/store/config/orders');
$this
->clickLink('Create custom order status');
$edit = [
'id' => strtolower($this
->randomMachineName()),
'name' => $this
->randomMachineName(),
'state' => 'in_checkout',
'weight' => -15,
];
$this
->submitForm($edit, 'Create');
$this
->assertEquals($edit['id'], uc_order_state_default('in_checkout'), 'uc_order_state_default() returns lowest weight status.');
// Set "in checkout" state to default to the new status.
$this
->submitForm([
'order_states[in_checkout][default]' => $edit['id'],
], 'Save configuration');
// Verify that state defaults to custom status.
$assert
->fieldValueEquals('order_states[in_checkout][default]', $edit['id']);
$order = $this
->ucCreateOrder($this->customer);
$this
->assertEquals($edit['id'], $order
->getStatusId(), 'Order has correct custom status.');
}