PHP 7.4.33
Preview: CreditCardTest.php Size: 5.10 KB
/home/godevadmin/www/admin/braintree/final/braintree/tests/unit/CreditCardTest.php

<?php
namespace Test\Unit;

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

use DateTime;
use Test\Setup;
use Braintree;

class CreditCardTest extends Setup
{
    public function testGet_givesErrorIfInvalidProperty()
    {
        $this->setExpectedException('PHPUnit_Framework_Error', 'Undefined property on Braintree\CreditCard: foo');
        $cc = Braintree\CreditCard::factory([]);
        $cc->foo;
    }

    public function testCreate_throwsIfInvalidKey()
    {
        $this->setExpectedException('InvalidArgumentException', 'invalid keys: invalidKey');
        Braintree\CreditCard::create(['invalidKey' => 'foo']);
    }

    public function testIsDefault()
    {
        $creditCard = Braintree\CreditCard::factory(['default' => true]);
        $this->assertTrue($creditCard->isDefault());

        $creditCard = Braintree\CreditCard::factory(['default' => false]);
        $this->assertFalse($creditCard->isDefault());
    }

    public function testMaskedNumber()
    {
        $creditCard = Braintree\CreditCard::factory(['bin' => '123456', 'last4' => '7890']);
        $this->assertEquals('123456******7890', $creditCard->maskedNumber);
    }

    public function testCreateSignature()
    {
        $expected = [
            'billingAddressId', 'cardholderName', 'cvv', 'number', 'deviceSessionId',
            'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode',
            'deviceData', 'fraudMerchantId', 'paymentMethodNonce',
            ['options' => ['makeDefault', 'verificationMerchantAccountId', 'verifyCard', 'verificationAmount', 'venmoSdkSession', 'failOnDuplicatePaymentMethod']],
            [
                'billingAddress' => [
                    'firstName',
                    'lastName',
                    'company',
                    'countryCodeAlpha2',
                    'countryCodeAlpha3',
                    'countryCodeNumeric',
                    'countryName',
                    'extendedAddress',
                    'locality',
                    'region',
                    'postalCode',
                    'streetAddress',
                ],
            ],
            'customerId'
        ];
        $this->assertEquals($expected, Braintree\CreditCardGateway::createSignature());
    }

    public function testUpdateSignature()
    {
        $expected = [
            'billingAddressId', 'cardholderName', 'cvv', 'number', 'deviceSessionId',
            'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode',
            'deviceData', 'fraudMerchantId', 'paymentMethodNonce',
            [
                'options' => [
                    'makeDefault',
                    'verificationMerchantAccountId',
                    'verifyCard',
                    'verificationAmount',
                    'venmoSdkSession',
                    'failOnDuplicatePaymentMethod',
                ]
            ],
            [
                'billingAddress' => [
                    'firstName',
                    'lastName',
                    'company',
                    'countryCodeAlpha2',
                    'countryCodeAlpha3',
                    'countryCodeNumeric',
                    'countryName',
                    'extendedAddress',
                    'locality',
                    'region',
                    'postalCode',
                    'streetAddress',
                    [
                        'options' => [
                            'updateExisting'
                        ]
                    ]
                ],
            ],
        ];
        $this->assertEquals($expected, Braintree\CreditCardGateway::updateSignature());
    }

    public function testErrorsOnFindWithBlankArgument()
    {
        $this->setExpectedException('InvalidArgumentException');
        Braintree\CreditCard::find('');
    }

    public function testErrorsOnFindWithWhitespaceArgument()
    {
        $this->setExpectedException('InvalidArgumentException');
        Braintree\CreditCard::find('  ');
    }

    public function testErrorsOnFindWithWhitespaceCharacterArgument()
    {
        $this->setExpectedException('InvalidArgumentException');
        Braintree\CreditCard::find('\t');
    }

    public function testVerificationIsLatestVerification()
    {
        $creditCard = Braintree\CreditCard::factory(
            [
                'verifications' => [
                    [
                        'id' => '123',
                        'createdAt' => DateTime::createFromFormat('Ymd', '20121212')
                    ],
                    [
                        'id' => '932',
                        'createdAt' => DateTime::createFromFormat('Ymd', '20121215')
                    ],
                    [
                        'id' => '456',
                        'createdAt' => DateTime::createFromFormat('Ymd', '20121213')
                    ]
                ]
            ]
        );

        $this->assertEquals('932', $creditCard->verification->id);
    }
}

Directory Contents

Dirs: 2 × Files: 35

Name Size Perms Modified Actions
ClientApi DIR
- drwxrwxr-x 2023-11-07 19:59:44
Edit Download
Result DIR
- drwxrwxr-x 2023-11-07 19:59:44
Edit Download
921 B lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
2.32 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
726 B lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
18.29 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
5.10 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
769 B lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.95 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
3.57 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
647 B lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.38 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
962 B lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.66 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
2.07 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.09 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
3.11 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
590 B lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.49 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.97 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
2.74 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
3.81 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.32 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.03 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
2.98 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
534 B lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
2.17 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
528 B lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.10 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
4.32 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.04 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
795 B lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
508 B lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
7.99 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
26.61 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
3.04 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
18.76 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download

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