Skip to content

Commit a53454a

Browse files
committed
Additional tests
1 parent 81beab9 commit a53454a

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

src/Omnipay/Common/AbstractGateway.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public function initialize(array $parameters = array())
6363
return $this;
6464
}
6565

66+
public function getDefaultParameters()
67+
{
68+
return array();
69+
}
70+
6671
public function getParameters()
6772
{
6873
return $this->parameters->all();

tests/Omnipay/Common/AbstractGatewayTest.php

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,123 @@
44

55
use Mockery as m;
66
use Omnipay\Tests\TestCase;
7+
use Symfony\Component\HttpFoundation\ParameterBag;
78

89
class AbstractGatewayTest extends TestCase
910
{
1011
public function setUp()
1112
{
1213
$this->gateway = m::mock("\Omnipay\Common\AbstractGateway")->makePartial();
14+
$this->gateway->initialize();
1315
}
1416

1517
public function testGetShortName()
1618
{
1719
$this->assertSame('\\'.get_class($this->gateway), $this->gateway->getShortName());
1820
}
21+
22+
public function testInitializeDefaults()
23+
{
24+
$defaults = array(
25+
'currency' => 'AUD', // fixed default type
26+
'username' => array('joe', 'fred'), // enum default type
27+
);
28+
$this->gateway->shouldReceive('getDefaultParameters')->once()
29+
->andReturn($defaults);
30+
31+
$this->gateway->initialize();
32+
33+
$expected = array(
34+
'currency' => 'AUD',
35+
'username' => 'joe',
36+
);
37+
$this->assertSame($expected, $this->gateway->getParameters());
38+
}
39+
40+
public function testInitializeParameters()
41+
{
42+
$this->gateway->shouldReceive('getDefaultParameters')->once()
43+
->andReturn(array('currency' => 'AUD'));
44+
45+
$this->gateway->initialize(array(
46+
'currency' => 'USD',
47+
'unknown' => '42',
48+
));
49+
50+
$this->assertSame(array('currency' => 'USD'), $this->gateway->getParameters());
51+
}
52+
53+
public function testGetDefaultParameters()
54+
{
55+
$this->assertSame(array(), $this->gateway->getDefaultParameters());
56+
}
57+
58+
public function testGetParameters()
59+
{
60+
$this->gateway->setTestMode(true);
61+
62+
$this->assertSame(array('testMode' => true), $this->gateway->getParameters());
63+
}
64+
65+
public function testTestMode()
66+
{
67+
$this->assertSame($this->gateway, $this->gateway->setTestMode(true));
68+
$this->assertSame(true, $this->gateway->getTestMode());
69+
}
70+
71+
public function testCurrency()
72+
{
73+
$this->assertSame($this->gateway, $this->gateway->setCurrency('USD'));
74+
$this->assertSame('USD', $this->gateway->getCurrency());
75+
}
76+
77+
public function testSupportsAuthorize()
78+
{
79+
$this->assertFalse($this->gateway->supportsAuthorize());
80+
}
81+
82+
public function testSupportsCompleteAuthorize()
83+
{
84+
$this->assertFalse($this->gateway->supportsCompleteAuthorize());
85+
}
86+
87+
public function testSupportsCapture()
88+
{
89+
$this->assertFalse($this->gateway->supportsCapture());
90+
}
91+
92+
public function testSupportsPurchase()
93+
{
94+
$this->assertFalse($this->gateway->supportsPurchase());
95+
}
96+
97+
public function testSupportsCompletePurchase()
98+
{
99+
$this->assertFalse($this->gateway->supportsCompletePurchase());
100+
}
101+
102+
public function testSupportsRefund()
103+
{
104+
$this->assertFalse($this->gateway->supportsRefund());
105+
}
106+
107+
public function testSupportsVoid()
108+
{
109+
$this->assertFalse($this->gateway->supportsVoid());
110+
}
111+
112+
public function testSupportsCreateCard()
113+
{
114+
$this->assertFalse($this->gateway->supportsCreateCard());
115+
}
116+
117+
public function testSupportsDeleteCard()
118+
{
119+
$this->assertFalse($this->gateway->supportsDeleteCard());
120+
}
121+
122+
public function testSupportsUpdateCard()
123+
{
124+
$this->assertFalse($this->gateway->supportsUpdateCard());
125+
}
19126
}

0 commit comments

Comments
 (0)