You are here

function Braintree_SubscriptionTest::testCreate_withDescriptorValidation in Commerce Braintree 7

File

braintree_php/tests/integration/SubscriptionTest.php, line 568

Class

Braintree_SubscriptionTest

Code

function testCreate_withDescriptorValidation() {
  $result = Braintree_Subscription::create(array(
    'descriptor' => array(
      'name' => 'xxxxxx',
      'phone' => 'xxxx',
    ),
  ));
  $this
    ->assertFalse($result->success);
  $subscription = $result->subscription;
  $errors = $result->errors
    ->forKey('subscription')
    ->forKey('descriptor')
    ->onAttribute('name');
  $this
    ->assertEquals(Braintree_Error_Codes::DESCRIPTOR_NAME_FORMAT_IS_INVALID, $errors[0]->code);
  $errors = $result->errors
    ->forKey('subscription')
    ->forKey('descriptor')
    ->onAttribute('phone');
  $this
    ->assertEquals(Braintree_Error_Codes::DESCRIPTOR_PHONE_FORMAT_IS_INVALID, $errors[0]->code);
}