Skip to content

Commit 5db9946

Browse files
author
Konstantinos Christofilos
committed
Added unit tests for new functionality
1 parent 168371e commit 5db9946

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

tests/GatewayTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ public function setUp()
2424
);
2525
}
2626

27+
public function testFindCustomer()
28+
{
29+
$request = $this->gateway->findCustomer(1);
30+
$this->assertInstanceOf('\Omnipay\Braintree\Message\FindCustomerRequest', $request);
31+
$this->assertEquals(1, $request->getCustomerId());
32+
}
33+
2734
public function testAuthorize()
2835
{
2936
$request = $this->gateway->authorize(array('amount' => '10.00'));
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
namespace Omnipay\Braintree\Message;
3+
4+
use Omnipay\Tests\TestCase;
5+
6+
class FindCustomerRequestTest extends TestCase
7+
{
8+
/**
9+
* @var CreateCustomerRequest
10+
*/
11+
private $request;
12+
13+
public function setUp()
14+
{
15+
parent::setUp();
16+
17+
$gateway = $this->buildMockGateway();
18+
$this->request = new FindCustomerRequest($this->getHttpClient(), $this->getHttpRequest(), $gateway);
19+
$this->request->initialize(array('customerId' => 1));
20+
}
21+
22+
public function testGetData()
23+
{
24+
$data = $this->request->getData();
25+
$this->assertNull($data);
26+
}
27+
28+
public function testSendData()
29+
{
30+
$data = array();
31+
$response = $this->request->sendData($data);
32+
33+
$this->assertInstanceOf('Omnipay\Braintree\Message\CustomerResponse', $response);
34+
}
35+
36+
protected function buildMockGateway()
37+
{
38+
$gateway = $this->getMockBuilder('\Braintree_Gateway')
39+
->disableOriginalConstructor()
40+
->setMethods(array(
41+
'customer'
42+
))
43+
->getMock();
44+
45+
$customer = $this->getMockBuilder('\Braintree_CustomerGateway')
46+
->disableOriginalConstructor()
47+
->getMock();
48+
49+
$gateway->expects($this->any())
50+
->method('customer')
51+
->will($this->returnValue($customer));
52+
53+
return $gateway;
54+
}
55+
}

0 commit comments

Comments
 (0)