You are here

public function CommerceNodeCheckoutBaseTest::checkout in Commerce Node Checkout 7

Start and complete the checkout process.

3 calls to CommerceNodeCheckoutBaseTest::checkout()
CommerceNodeCheckoutExpireTests::relistNode in commerce_node_checkout_expire/commerce_node_checkout_expire.test
Relist a given node and optionally checkout as well.
CommerceNodeCheckoutExpireTests::testCommerceNodeCheckoutExpire in commerce_node_checkout_expire/commerce_node_checkout_expire.test
Test everything we need to do with content, expiration, notifications, etc.
CommerceNodeCheckoutTests::testAnonymousPublishing in ./commerce_node_checkout.test
Test anonymous users can create content after payment.

File

./commerce_node_checkout.test, line 139
Provides tests for Commerce Node Checkout process.

Class

CommerceNodeCheckoutBaseTest
Base class for other test classes to extend.

Code

public function checkout() {

  // Go to the cart, if we're not yet there
  if (!$this
    ->isPath('cart')) {
    $this
      ->drupalGet('cart');
  }

  // Go to the checkout
  $this
    ->drupalPost(NULL, array(), t('Checkout'));

  // Make sure we got there
  $matches = array();
  preg_match('/checkout\\/([0-9]+)/', $this
    ->getUrl(), $matches);
  $this
    ->assertTrue(count($matches) == 2, 'User redirected to checkout');

  // Now we complete checkout form.
  $edit = array(
    'customer_profile_billing[commerce_customer_address][und][0][name_line]' => 'Joe Bloggs',
    'customer_profile_billing[commerce_customer_address][und][0][country]' => 'AU',
    'customer_profile_billing[commerce_customer_address][und][0][thoroughfare]' => '1 Some St',
    'customer_profile_billing[commerce_customer_address][und][0][locality]' => 'Somewhere',
    'customer_profile_billing[commerce_customer_address][und][0][administrative_area]' => 'QLD',
    'customer_profile_billing[commerce_customer_address][und][0][postal_code]' => '1234',
  );

  // If not logged in, provide an email address
  if (!$this->loggedInUser) {
    $edit['account[login][mail]'] = 'joe.bloggs@example.com';
  }
  $this
    ->drupalPost(NULL, $edit, t('Continue to next step'));

  // This is 'complete' purchase.
  $this
    ->drupalPost(NULL, array(), t('Continue to next step'));

  // Check order is complete.
  $this
    ->assertRaw('Checkout complete', 'Checkout was completed');
}