You are here

function Braintree_Error_ErrorCollectionTest::testOnHtmlField_returnsEmptyArrayIfNone in Commerce Braintree 7

File

braintree_php/tests/integration/Error/ErrorCollectionTest.php, line 43

Class

Braintree_Error_ErrorCollectionTest

Code

function testOnHtmlField_returnsEmptyArrayIfNone() {
  $result = Braintree_Customer::create(array(
    'email' => 'invalid',
    'creditCard' => array(
      'number' => '5105105105105100',
      'expirationDate' => '05/12',
      'billingAddress' => array(
        'streetAddress' => '1 E Main St',
      ),
    ),
  ));
  $this
    ->assertEquals(false, $result->success);
  $errors = $result->errors
    ->onHtmlField('customer[email]');
  $this
    ->assertEquals(Braintree_Error_Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code);
  $this
    ->assertEquals(array(), $result->errors
    ->onHtmlField('customer[credit_card][number]'));
  $this
    ->assertEquals(array(), $result->errors
    ->onHtmlField('customer[credit_card][billing_address][country_name]'));
}