public function UbercartCartCheckoutTestCase::testCheckoutComplete in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_cart/uc_cart.test \UbercartCartCheckoutTestCase::testCheckoutComplete()
Tests checkout complete functioning.
File
- uc_cart/
tests/ uc_cart.test, line 405 - Shopping cart and checkout tests.
Class
- UbercartCartCheckoutTestCase
- Tests the cart and checkout functionality.
Code
public function testCheckoutComplete() {
// Payment notification is received first.
$order_data = array(
'primary_email' => 'simpletest@ubercart.org',
);
$order = $this
->createOrder($order_data);
uc_payment_enter($order->order_id, 'SimpleTest', $order->order_total);
$output = uc_cart_complete_sale($order);
// Check that a new account was created.
$this
->assertTrue(strpos($output['#message'], 'new account has been created') !== FALSE, 'Checkout message mentions new account.');
// 2 e-mails: new account, customer invoice.
$mails = $this
->drupalGetMails();
$this
->assertEqual(count($mails), 2, '2 e-mails were sent.');
variable_del('drupal_test_email_collector');
$password = $mails[0]['params']['account']->password;
$this
->assertTrue(!empty($password), 'New password is not empty.');
// In D7, new account emails do not contain the password.
//$this->assertTrue(strpos($mails[0]['body'], $password) !== FALSE, 'Mail body contains password.');
// Different user, sees the checkout page first.
$order_data = array(
'primary_email' => 'simpletest2@ubercart.org',
);
$order = $this
->createOrder($order_data);
$output = uc_cart_complete_sale($order, TRUE);
uc_payment_enter($order->order_id, 'SimpleTest', $order->order_total);
// 2 e-mails: new account, customer invoice.
$mails = $this
->drupalGetMails();
$this
->assertEqual(count($mails), 2, '2 e-mails were sent.');
variable_del('drupal_test_email_collector');
$password = $mails[0]['params']['account']->password;
$this
->assertTrue(!empty($password), 'New password is not empty.');
// In D7, new account emails do not contain the password.
//$this->assertTrue(strpos($mails[0]['body'], $password) !== FALSE, 'Mail body contains password.');
// Same user, new order.
$order = $this
->createOrder($order_data);
$output = uc_cart_complete_sale($order, TRUE);
uc_payment_enter($order->order_id, 'SimpleTest', $order->order_total);
// Check that no new account was created.
$this
->assertTrue(strpos($output['#message'], 'order has been attached to the account') !== FALSE, 'Checkout message mentions existing account.');
// 1 e-mail: customer invoice.
$mails = $this
->drupalGetMails();
$this
->assertEqual(count($mails), 1, '1 e-mail was sent.');
variable_del('drupal_test_email_collector');
}