You are here

function Braintree_TransactionTest::testSale_withInvalidCustomField in Commerce Braintree 7

File

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

Class

Braintree_TransactionTest

Code

function testSale_withInvalidCustomField() {
  $result = Braintree_Transaction::sale(array(
    'amount' => '100.00',
    'creditCard' => array(
      'number' => '5105105105105100',
      'expirationDate' => '05/12',
    ),
    'customFields' => array(
      'invalidKey' => 'custom value',
    ),
  ));
  $this
    ->assertFalse($result->success);
  $errors = $result->errors
    ->forKey('transaction')
    ->onAttribute('customFields');
  $this
    ->assertEquals(Braintree_Error_Codes::TRANSACTION_CUSTOM_FIELD_IS_INVALID, $errors[0]->code);
  $this
    ->assertEquals('Custom field is invalid: invalidKey.', $errors[0]->message);
}