You are here

function Braintree_TransactionTest::testSale_andStoreShippingAddressInVault in Commerce Braintree 7

File

braintree_php/tests/integration/TransactionTest.php, line 491

Class

Braintree_TransactionTest

Code

function testSale_andStoreShippingAddressInVault() {
  $customer = Braintree_Customer::create(array(
    'firstName' => 'Mike',
    'lastName' => 'Jones',
    'company' => 'Jones Co.',
    'email' => 'mike.jones@example.com',
    'phone' => '419.555.1234',
    'fax' => '419.555.1235',
    'website' => 'http://example.com',
  ))->customer;
  $transaction = Braintree_Transaction::sale(array(
    'amount' => '100.00',
    'customerId' => $customer->id,
    'creditCard' => array(
      'cardholderName' => 'The Cardholder',
      'number' => Braintree_Test_CreditCardNumbers::$visa,
      'expirationDate' => '05/12',
    ),
    'shipping' => array(
      'firstName' => 'Darren',
      'lastName' => 'Stevens',
    ),
    'options' => array(
      'storeInVault' => true,
      'storeShippingAddressInVault' => true,
    ),
  ))->transaction;
  $customer = Braintree_Customer::find($customer->id);
  $this
    ->assertEquals('Darren', $customer->addresses[0]->firstName);
  $this
    ->assertEquals('Stevens', $customer->addresses[0]->lastName);
}