forked from yabacon/paystack-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaystackTest.php
More file actions
113 lines (96 loc) · 3.24 KB
/
PaystackTest.php
File metadata and controls
113 lines (96 loc) · 3.24 KB
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
<?php
namespace Yabacon\Paystack\Tests;
use Yabacon\Paystack;
use Yabacon\Paystack\Helpers\Router;
use Yabacon\Paystack\Test\Mock\CustomRoute;
use \Yabacon\Paystack\Exception\ValidationException;
class PaystackTest extends \PHPUnit\Framework\TestCase
{
public function testInitializeWithInvalidSecretKey()
{
$this->expectException(\InvalidArgumentException::class);
$r = new Paystack('p');
}
public function testVersion()
{
$this->assertEquals("2.2.0", Paystack::VERSION);
}
public function testDisableFileGetContentsFallback()
{
Paystack::disableFileGetContentsFallback();
$this->assertFalse(Paystack::$fallback_to_file_get_contents);
}
public function testEnableFileGetContentsFallback()
{
Paystack::enableFileGetContentsFallback();
$this->assertTrue(Paystack::$fallback_to_file_get_contents);
}
public function testSetUseGuzzle()
{
$r = new Paystack('sk_');
$r->useGuzzle();
$this->assertTrue($r->use_guzzle);
}
public function testGetShouldBringRouter()
{
$r = new Paystack('sk_');
$this->assertInstanceOf(Router::class, $r->customer);
$this->expectException(ValidationException::class);
$this->assertNull($r->nonexistent);
}
public function testListInvalidResource()
{
$r = new Paystack('sk_');
$this->expectException(\InvalidArgumentException::class);
$this->assertNull($r->nonexistents());
}
public function testFetchInvalidResource()
{
$r = new Paystack('sk_');
$this->expectException(ValidationException::class);
$this->assertNull($r->nonexistent(1));
}
public function testFetchWithInvalidParams2()
{
$r = new Paystack('sk_');
$this->expectException(\InvalidArgumentException::class);
$this->assertNull($r->customer());
}
public function testFetchWithInvalidParams3()
{
$r = new Paystack('sk_');
$this->expectException(\InvalidArgumentException::class);
$this->assertNull($r->customers(1));
}
public function testUseRoutes()
{
$custom_routes = ['custom_route' => CustomRoute::class];
$r = new Paystack('sk_');
$r->useRoutes($custom_routes);
$this->assertTrue($r->custom_routes == $custom_routes);
}
public function testUseRoutesWithInvalidParams1()
{
$custom_routes = ['custom_route'];
$r = new Paystack('sk_');
$this->expectException(\InvalidArgumentException::class);
$r->useRoutes($custom_routes);
$this->assertNull($r->custom_routes);
}
public function testUseRoutesWithInvalidParams2()
{
$custom_routes = ['custom_route' => Paystack::class];
$r = new Paystack('sk_');
$this->expectException(\InvalidArgumentException::class);
$r->useRoutes($custom_routes);
$this->assertNull($r->custom_routes);
}
public function testUseRoutesWithInvalidParams3()
{
$custom_routes = ['balance' => CustomRoute::class];
$r = new Paystack('sk_');
$this->expectException(\InvalidArgumentException::class);
$r->useRoutes($custom_routes);
$this->assertNull($r->custom_routes);
}
}