|
4 | 4 |
|
5 | 5 | use Mockery as m;
|
6 | 6 | use Omnipay\Tests\TestCase;
|
| 7 | +use Symfony\Component\HttpFoundation\ParameterBag; |
7 | 8 |
|
8 | 9 | class AbstractGatewayTest extends TestCase
|
9 | 10 | {
|
10 | 11 | public function setUp()
|
11 | 12 | {
|
12 | 13 | $this->gateway = m::mock("\Omnipay\Common\AbstractGateway")->makePartial();
|
| 14 | + $this->gateway->initialize(); |
13 | 15 | }
|
14 | 16 |
|
15 | 17 | public function testGetShortName()
|
16 | 18 | {
|
17 | 19 | $this->assertSame('\\'.get_class($this->gateway), $this->gateway->getShortName());
|
18 | 20 | }
|
| 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 | + } |
19 | 126 | }
|
0 commit comments