Open Journal Systems  3.3.0
GatewayFactoryTest.php
1 <?php
2 
3 namespace Omnipay\Common;
4 
5 use Mockery as m;
6 use Omnipay\Tests\TestCase;
7 
8 class GatewayFactoryTest extends TestCase
9 {
10  public static function setUpBeforeClass()
11  {
12  m::mock('alias:Omnipay\\SpareChange\\TestGateway');
13  }
14 
15  public function setUp()
16  {
17  $this->factory = new GatewayFactory;
18  }
19 
20  public function testReplace()
21  {
22  $gateways = array('Foo');
23  $this->factory->replace($gateways);
24 
25  $this->assertSame($gateways, $this->factory->all());
26  }
27 
28  public function testRegister()
29  {
30  $this->factory->register('Bar');
31 
32  $this->assertSame(array('Bar'), $this->factory->all());
33  }
34 
35  public function testRegisterExistingGateway()
36  {
37  $this->factory->register('Milky');
38  $this->factory->register('Bar');
39  $this->factory->register('Bar');
40 
41  $this->assertSame(array('Milky', 'Bar'), $this->factory->all());
42  }
43 
45  {
46  $this->factory = m::mock('Omnipay\Common\GatewayFactory[getSupportedGateways]');
47  $this->factory->shouldReceive('getSupportedGateways')->once()
48  ->andReturn(array('SpareChange_Test'));
49 
50  $gateways = $this->factory->find();
51 
52  $this->assertContains('SpareChange_Test', $gateways);
53  $this->assertContains('SpareChange_Test', $this->factory->all());
54  }
55 
57  {
58  $this->factory = m::mock('Omnipay\Common\GatewayFactory[getSupportedGateways]');
59  $this->factory->shouldReceive('getSupportedGateways')->once()
60  ->andReturn(array('SpareChange_Gone'));
61 
62  $gateways = $this->factory->find();
63 
64  $this->assertEmpty($gateways);
65  $this->assertEmpty($this->factory->all());
66  }
67 
68  public function testCreateShortName()
69  {
70  $gateway = $this->factory->create('SpareChange_Test');
71  $this->assertInstanceOf('\\Omnipay\\SpareChange\\TestGateway', $gateway);
72  }
73 
74  public function testCreateFullyQualified()
75  {
76  $gateway = $this->factory->create('\\Omnipay\\SpareChange\\TestGateway');
77  $this->assertInstanceOf('\\Omnipay\\SpareChange\\TestGateway', $gateway);
78  }
79 
84  public function testCreateInvalid()
85  {
86  $gateway = $this->factory->create('Invalid');
87  }
88 
89  public function testGetSupportedGateways()
90  {
91  $gateways = $this->factory->getSupportedGateways();
92 
93  $this->assertContains('Stripe', $gateways);
94  }
95 }
Omnipay\Common\GatewayFactory
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/GatewayFactory.php:31
Omnipay\Common\GatewayFactoryTest
Definition: GatewayFactoryTest.php:8
Omnipay\Common\GatewayFactoryTest\testCreateFullyQualified
testCreateFullyQualified()
Definition: GatewayFactoryTest.php:74
Omnipay\Common\GatewayFactoryTest\testRegisterExistingGateway
testRegisterExistingGateway()
Definition: GatewayFactoryTest.php:35
Omnipay\Common\GatewayFactoryTest\testCreateInvalid
testCreateInvalid()
Definition: GatewayFactoryTest.php:84
Omnipay\Common\GatewayFactoryTest\testCreateShortName
testCreateShortName()
Definition: GatewayFactoryTest.php:68
Omnipay\Common\GatewayFactoryTest\testFindIgnoresUnavailableGateways
testFindIgnoresUnavailableGateways()
Definition: GatewayFactoryTest.php:56
Omnipay\Common\GatewayFactoryTest\testReplace
testReplace()
Definition: GatewayFactoryTest.php:20
Omnipay\Common\GatewayFactoryTest\testFindRegistersAvailableGateways
testFindRegistersAvailableGateways()
Definition: GatewayFactoryTest.php:44
Omnipay\Common\GatewayFactoryTest\setUp
setUp()
Definition: GatewayFactoryTest.php:15
Omnipay\Common\GatewayFactoryTest\testRegister
testRegister()
Definition: GatewayFactoryTest.php:28
Omnipay\Common
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/AbstractGateway.php:6
Omnipay\Common\GatewayFactoryTest\setUpBeforeClass
static setUpBeforeClass()
Definition: GatewayFactoryTest.php:10
Omnipay\Common\GatewayFactoryTest\testGetSupportedGateways
testGetSupportedGateways()
Definition: GatewayFactoryTest.php:89