function PaymentUbercartCheckoutWebTestCase::assertCheckout in Payment for Ubercart 7.2
Same name and namespace in other branches
- 7 tests/PaymentUbercartCheckoutWebTestCase.test \PaymentUbercartCheckoutWebTestCase::assertCheckout()
Executes the checkout process.
Parameters
integer $product_nid:
integer $pmid:
1 call to PaymentUbercartCheckoutWebTestCase::assertCheckout()
File
- tests/
PaymentUbercartCheckoutWebTestCase.test, line 61
Class
Code
function assertCheckout($product_nid, $pmid) {
$previous_order_id = $this
->getLastOrderID();
// Execute the checkout.
$this
->drupalPost('node/' . $product_nid, array(), t('Add to cart'));
$this
->drupalPost(NULL, array(), t('Checkout'));
$values = array(
'panes[customer][primary_email]' => 'b@b.b',
);
foreach (array(
'delivery',
'billing',
) as $type) {
$values['panes[' . $type . '][' . $type . '_first_name]'] = 'foo';
$values['panes[' . $type . '][' . $type . '_last_name]'] = 'foo';
$values['panes[' . $type . '][' . $type . '_street1]'] = 'foo';
$values['panes[' . $type . '][' . $type . '_city]'] = 'foo';
$values['panes[' . $type . '][' . $type . '_zone]'] = 1;
$values['panes[' . $type . '][' . $type . '_postal_code]'] = 'foo';
}
$this
->drupalPost(NULL, $values, t('Review order'));
$this
->drupalPost(NULL, array(), t('Submit order'));
// Test if a payment was added for the order.
$new_order_id = $this
->getLastOrderID();
$this
->assertNotEqual($previous_order_id, $new_order_id);
$pids = payment_ubercart_pids_load($new_order_id);
$payment = entity_load_unchanged('payment', end($pids));
$this
->assertTrue((bool) $payment);
if ($payment) {
$this
->assertEqual($payment
->getStatus()->status, PAYMENT_STATUS_SUCCESS);
}
$order = uc_order_load($new_order_id);
$this
->assertEqual($payment->uid, $order->uid);
}