You are here

function CommerceBraintreeTest::testCommerceBraintreeRequest in Commerce Braintree 7

Same name and namespace in other branches
  1. 7.3 tests/commerce_braintree.test \CommerceBraintreeTest::testCommerceBraintreeRequest()
  2. 7.2 tests/commerce_braintree.test \CommerceBraintreeTest::testCommerceBraintreeRequest()

File

tests/commerce_braintree.test, line 107
Functional tests for the commerce payment module user interface.

Class

CommerceBraintreeTest
Test payment user interface.

Code

function testCommerceBraintreeRequest() {
  $user = $this->web_user;

  // Log in as normal user.
  $this
    ->drupalLogin($user);
  $product = $this
    ->createDummyProduct($this
    ->randomName(), $this
    ->randomName(), $this->price, 'USD', $this->store_admin->uid);
  $this->order = $this
    ->createDummyOrder($user->uid, array(
    $product->product_id => 20,
  ));
  $edit = array();
  $edit['transaction[credit_card][number]'] = '4111111111111111';
  $edit['transaction[credit_card][cardholder_name]'] = $this
    ->getRandomName();
  $edit['transaction[credit_card][expiration_month]'] = '10';
  $edit['transaction[credit_card][expiration_year]'] = '2012';
  $edit['transaction[credit_card][cvv]'] = '123';
  $edit['tr_data'] = $this
    ->createTrDataInfo($this->order);
  $option = array();
  $option['method'] = 'POST';
  $option['data'] = drupal_http_build_query($edit);
  $url = Braintree_TransparentRedirect::url();
  $request = drupal_http_request($url, $option);
  $feedback = explode('?', $request->headers['location']);
  $result = Braintree_TransparentRedirect::confirm($feedback[1]);
}