function Braintree_Error_ValidationErrorCollectionTest::test_shallowAll_givesAllErrorsShallowly in Commerce Braintree 7
File
- braintree_php/
tests/ integration/ Error/ ValidationErrorCollectionTest.php, line 14
Class
Code
function test_shallowAll_givesAllErrorsShallowly() {
$result = Braintree_Customer::create(array(
'email' => 'invalid',
'creditCard' => array(
'number' => '1234123412341234',
'expirationDate' => 'invalid',
'billingAddress' => array(
'countryName' => 'invalid',
),
),
));
$this
->assertEquals(array(), $result->errors
->shallowAll());
$expectedCustomerErrors = array(
Braintree_Error_Codes::CUSTOMER_EMAIL_IS_INVALID,
);
$actualCustomerErrors = $result->errors
->forKey('customer')
->shallowAll();
$this
->assertEquals($expectedCustomerErrors, self::mapValidationErrorsToCodes($actualCustomerErrors));
$expectedCreditCardErrors = array(
Braintree_Error_Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID,
Braintree_Error_Codes::CREDIT_CARD_NUMBER_IS_INVALID,
);
$actualCreditCardErrors = $result->errors
->forKey('customer')
->forKey('creditCard')
->shallowAll();
$this
->assertEquals($expectedCreditCardErrors, self::mapValidationErrorsToCodes($actualCreditCardErrors));
}