public function CartCheckoutTest::testCheckoutNewUsername in Ubercart 8.4
Tests generating a new account at checkout.
File
- uc_cart/
tests/ src/ Functional/ CartCheckoutTest.php, line 430
Class
- CartCheckoutTest
- Tests the cart and checkout functionality.
Namespace
Drupal\Tests\uc_cart\FunctionalCode
public function testCheckoutNewUsername() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
// Configure the checkout for this test.
$this
->drupalLogin($this->adminUser);
$settings = [
// Allow customer to specify username.
'uc_cart_new_account_name' => TRUE,
// Disable address panes.
'panes[delivery][status]' => FALSE,
'panes[billing][status]' => FALSE,
];
$this
->drupalGet('admin/store/config/checkout');
$this
->submitForm($settings, 'Save configuration');
$this
->drupalLogout();
// Test with an account that already exists.
$this
->addToCart($this->product);
$edit = [
'panes[customer][primary_email]' => $this
->randomMachineName(8) . '@example.com',
'panes[customer][new_account][name]' => $this->adminUser->name->value,
];
$this
->drupalGet('cart/checkout');
$this
->submitForm($edit, 'Review order');
$assert
->pageTextContains('The username ' . $this->adminUser->name->value . ' is already taken.');
// Let the account be automatically created instead.
$edit = [
'panes[customer][primary_email]' => $this
->randomMachineName(8) . '@example.com',
'panes[customer][new_account][name]' => '',
];
$this
->drupalGet('cart/checkout');
$this
->submitForm($edit, 'Review order');
$this
->submitForm([], 'Submit order');
$assert
->pageTextContains('Your order is complete!');
$assert
->pageTextContains('A new account has been created');
}