forked from ekyna/PayumMonetico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMoneticoGatewayFactoryTest.php
121 lines (90 loc) · 3.46 KB
/
MoneticoGatewayFactoryTest.php
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
namespace Ekyna\Component\Payum\Monetico;
use Ekyna\Component\Payum\Monetico\Api\Api;
use Payum\Core\CoreGatewayFactory;
use Payum\Core\Exception\LogicException;
use Payum\Core\Gateway;
use Payum\Core\GatewayFactory;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
/**
* Class MoneticoGatewayFactoryTest
* @package Ekyna\Component\Payum\Monetico
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class MoneticoGatewayFactoryTest extends TestCase
{
public function test_extends_GatewayFactory()
{
$rc = new ReflectionClass(MoneticoGatewayFactory::class);
$this->assertTrue($rc->isSubclassOf(GatewayFactory::class));
}
public function test_construct_without_any_arguments()
{
new MoneticoGatewayFactory();
$this->assertTrue(true);
}
public function test_create_gateway()
{
$factory = new MoneticoGatewayFactory();
$gateway = $factory->create([
'mode' => Api::MODE_PRODUCTION,
'tpe' => '123456',
'key' => '123456',
'company' => 'foobar',
]);
$this->assertInstanceOf(Gateway::class, $gateway);
}
public function test_create_config()
{
$factory = new MoneticoGatewayFactory();
$config = $factory->createConfig();
$this->assertIsArray($config);
$this->assertNotEmpty($config);
}
public function test_config_defaults_passed_in_constructor()
{
$factory = new MoneticoGatewayFactory([
'foo' => 'fooVal',
'bar' => 'barVal',
]);
$config = $factory->createConfig();
$this->assertIsArray($config);
$this->assertArrayHasKey('foo', $config);
$this->assertEquals('fooVal', $config['foo']);
$this->assertArrayHasKey('bar', $config);
$this->assertEquals('barVal', $config['bar']);
}
public function test_config_contains_factory_name_and_title()
{
$factory = new MoneticoGatewayFactory();
$config = $factory->createConfig();
$this->assertIsArray($config);
$this->assertArrayHasKey('payum.factory_name', $config);
$this->assertEquals('monetico', $config['payum.factory_name']);
$this->assertArrayHasKey('payum.factory_title', $config);
$this->assertEquals('Monetico', $config['payum.factory_title']);
}
public function test_throw_if_required_options_not_passed()
{
$this->expectException(LogicException::class);
$this->expectExceptionMessage('The mode, tpe, key, company fields are required.');
$factory = new MoneticoGatewayFactory();
$factory->create();
}
public function test_configure_paths()
{
$factory = new MoneticoGatewayFactory();
$config = $factory->createConfig();
$this->assertIsArray($config);
$this->assertNotEmpty($config);
$this->assertIsArray($config['payum.paths']);
$this->assertNotEmpty($config['payum.paths']);
$this->assertArrayHasKey('PayumCore', $config['payum.paths']);
$this->assertStringEndsWith('Resources/views', $config['payum.paths']['PayumCore']);
$this->assertTrue(file_exists($config['payum.paths']['PayumCore']));
$this->assertArrayHasKey('EkynaPayumMonetico', $config['payum.paths']);
$this->assertStringEndsWith('Resources/views', $config['payum.paths']['EkynaPayumMonetico']);
$this->assertTrue(file_exists($config['payum.paths']['EkynaPayumMonetico']));
}
}