You are here

function Braintree_TransactionTest::testSale_withDescriptorValidation in Commerce Braintree 7

File

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

Class

Braintree_TransactionTest

Code

function testSale_withDescriptorValidation() {
  $result = Braintree_Transaction::sale(array(
    'amount' => '100.00',
    'creditCard' => array(
      'number' => '5105105105105100',
      'expirationDate' => '05/12',
    ),
    'descriptor' => array(
      'name' => 'badcompanyname12*badproduct12',
      'phone' => '%bad4445555',
    ),
  ));
  $this
    ->assertFalse($result->success);
  $transaction = $result->transaction;
  $errors = $result->errors
    ->forKey('transaction')
    ->forKey('descriptor')
    ->onAttribute('name');
  $this
    ->assertEquals(Braintree_Error_Codes::DESCRIPTOR_NAME_FORMAT_IS_INVALID, $errors[0]->code);
  $errors = $result->errors
    ->forKey('transaction')
    ->forKey('descriptor')
    ->onAttribute('phone');
  $this
    ->assertEquals(Braintree_Error_Codes::DESCRIPTOR_PHONE_FORMAT_IS_INVALID, $errors[0]->code);
}