CustomerTest.php
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace Test\Unit;
require_once dirname(__DIR__) . '/Setup.php';
use Test\Setup;
use Braintree;
class CustomerTest extends Setup
{
public function testGet_givesErrorIfInvalidProperty()
{
$this->setExpectedException('PHPUnit_Framework_Error', 'Undefined property on Braintree\Customer: foo');
$c = Braintree\Customer::factory([]);
$c->foo;
}
public function testUpdateSignature_doesNotAlterOptionsInCreditCardUpdateSignature()
{
Braintree\CustomerGateway::updateSignature();
foreach (Braintree\CreditCardGateway::updateSignature() as $key => $value) {
if(is_array($value) and array_key_exists('options', $value)) {
$this->assertEquals([
'makeDefault',
'verificationMerchantAccountId',
'verifyCard',
'verificationAmount',
'verificationAccountType',
'venmoSdkSession',
'failOnDuplicatePaymentMethod',
], $value['options']);
}
}
}
public function testCreateSignature_doesNotIncludeCustomerIdOnCreditCard()
{
$signature = Braintree\CustomerGateway::createSignature();
$creditCardSignatures = array_filter($signature, 'Test\Unit\CustomerTest::findCreditCardArray');
$creditCardSignature = array_shift($creditCardSignatures)['creditCard'];
$this->assertNotContains('customerId', $creditCardSignature);
}
public function findCreditCardArray($el)
{
return is_array($el) && array_key_exists('creditCard', $el);
}
public function testFindErrorsOnBlankId()
{
$this->setExpectedException('InvalidArgumentException');
Braintree\Customer::find('');
}
public function testFindErrorsOnWhitespaceId()
{
$this->setExpectedException('InvalidArgumentException');
Braintree\Customer::find('\t');
}
}