PHP 7.4.33
Preview: UsBankAccountTest.php Size: 4.28 KB
/home/godevadmin/www/admin/braintree/final/braintree_php-master/tests/integration/UsBankAccountTest.php

<?php
namespace Test\Integration;

require_once dirname(__DIR__) . '/Setup.php';

use Test;
use Test\Setup;
use Braintree;

class UsBankAccountAccountTest extends Setup
{


    public function testReturnUsBankAccount()
    {
        $customer = Braintree\Customer::createNoValidate();
        $http = new HttpClientApi(Braintree\Configuration::$global);
        $nonce = Test\Helper::generateValidUsBankAccountNonce();

        $result = Braintree\PaymentMethod::create([
            'customerId' => $customer->id,
            'paymentMethodNonce' => $nonce
        ]);

        $foundUsBankAccount = $result->paymentMethod;
        $this->assertInstanceOf('Braintree\UsBankAccount', $foundUsBankAccount);
        $this->assertEquals('021000021', $foundUsBankAccount->routingNumber);
        $this->assertEquals('1234', $foundUsBankAccount->last4);
        $this->assertEquals('checking', $foundUsBankAccount->accountType);
        $this->assertEquals('Dan Schulman', $foundUsBankAccount->accountHolderName);
        $this->assertRegExp('/CHASE/', $foundUsBankAccount->bankName);
        $this->assertEquals('cl mandate text', $foundUsBankAccount->achMandate->text);
        $this->assertEquals('DateTime', get_class($foundUsBankAccount->achMandate->acceptedAt));
        $this->assertEquals(true, $foundUsBankAccount->default);
    }

    public function testFind()
    {
        $customer = Braintree\Customer::createNoValidate();
        $http = new HttpClientApi(Braintree\Configuration::$global);
        $nonce = Test\Helper::generateValidUsBankAccountNonce();

        $result = Braintree\PaymentMethod::create([
            'customerId' => $customer->id,
            'paymentMethodNonce' => $nonce
        ]);

        $foundUsBankAccount= Braintree\UsBankAccount::find($result->paymentMethod->token);
        $this->assertInstanceOf('Braintree\UsBankAccount', $foundUsBankAccount);
        $this->assertEquals('021000021', $foundUsBankAccount->routingNumber);
        $this->assertEquals('1234', $foundUsBankAccount->last4);
        $this->assertEquals('checking', $foundUsBankAccount->accountType);
        $this->assertEquals('Dan Schulman', $foundUsBankAccount->accountHolderName);
        $this->assertRegExp('/CHASE/', $foundUsBankAccount->bankName);
        $this->assertEquals('cl mandate text', $foundUsBankAccount->achMandate->text);
        $this->assertEquals('DateTime', get_class($foundUsBankAccount->achMandate->acceptedAt));
        $this->assertEquals(true, $foundUsBankAccount->default);
    }

    public function testFind_throwsIfCannotBeFound()
    {
        $this->setExpectedException('Braintree\Exception\NotFound');
        Braintree\UsBankAccount::find(Test\Helper::generateInvalidUsBankAccountNonce());
    }

    public function testSale_createsASaleUsingGivenToken()
    {
        $customer = Braintree\Customer::createNoValidate();
        $http = new HttpClientApi(Braintree\Configuration::$global);
        $nonce = Test\Helper::generateValidUsBankAccountNonce();

        $result = Braintree\PaymentMethod::create([
            'customerId' => $customer->id,
            'paymentMethodNonce' => $nonce
        ]);

        $result = Braintree\UsBankAccount::sale($result->paymentMethod->token, [
            'merchantAccountId' => 'us_bank_merchant_account',
            'amount' => '100.00'
        ]);

        $this->assertTrue($result->success);
        $transaction = $result->transaction;
        $this->assertEquals(Braintree\Transaction::SETTLEMENT_PENDING, $transaction->status);
        $this->assertEquals(Braintree\Transaction::SALE, $transaction->type);
        $this->assertEquals('100.00', $transaction->amount);
        $this->assertEquals('021000021', $transaction->usBankAccount->routingNumber);
        $this->assertEquals('1234', $transaction->usBankAccount->last4);
        $this->assertEquals('checking', $transaction->usBankAccount->accountType);
        $this->assertEquals('Dan Schulman', $transaction->usBankAccount->accountHolderName);
        $this->assertRegExp('/CHASE/', $transaction->usBankAccount->bankName);
        $this->assertEquals('cl mandate text', $transaction->usBankAccount->achMandate->text);
        $this->assertEquals('DateTime', get_class($transaction->usBankAccount->achMandate->acceptedAt));
    }
}

Directory Contents

Dirs: 2 × Files: 31

Name Size Perms Modified Actions
Error DIR
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
Result DIR
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.97 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
12.84 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
6.95 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
55.91 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
11.20 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.84 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
7.68 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
58.84 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.22 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
3.09 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.93 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
4.58 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
3.63 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
29.95 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
10.17 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
3.35 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
13.75 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.60 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
64.46 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
11.34 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
4.77 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
3.51 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.49 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
17.89 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
50.99 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.92 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
5.40 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
65.59 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
171.04 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
12.51 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
4.28 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).