Skip to content

Commit 67ecd0f

Browse files
feat(paystack): Add preliminary tests
1 parent 2cf9cda commit 67ecd0f

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
"require": {
1414
"php": ">=5.5.9",
1515
"illuminate/support": "5.2.*",
16+
"illuminate/container": "5.2.*",
1617
"guzzlehttp/guzzle": "~5.0"
1718
},
1819
"require-dev": {
1920
"phpunit/phpunit" : "4.*",
2021
"scrutinizer/ocular": "~1.1",
21-
"satooshi/php-coveralls": "^0.7.0"
22+
"satooshi/php-coveralls": "^0.7.0",
23+
"mockery/mockery": ">=0.7.2"
2224
},
2325
"autoload": {
2426
"psr-4": {

src/Paystack.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Unicodeveloper\Paystack;
1313

1414
use GuzzleHttp\Client;
15+
use Illuminate\Support\Facades\Config;
1516

1617
class Paystack {
1718

@@ -67,7 +68,7 @@ public function __construct()
6768
*/
6869
public function setBaseUrl()
6970
{
70-
$this->baseUrl = config('paystack.paymentUrl');
71+
$this->baseUrl = Config::get('paystack.paymentUrl');
7172
}
7273

7374
/**
@@ -76,7 +77,7 @@ public function setBaseUrl()
7677
*/
7778
public function setKey()
7879
{
79-
$this->secretKey = config('paystack.secretKey');
80+
$this->secretKey = Config::get('paystack.secretKey');
8081
}
8182

8283
/**

tests/PaystackTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,50 @@
1111

1212
namespace Unicodeveloper\Paystack\Test;
1313

14+
use Mockery as m;
15+
use GuzzleHttp\Client;
1416
use PHPUnit_Framework_TestCase;
1517
use Unicodeveloper\Paystack\Paystack;
18+
use Illuminate\Support\Facades\Config;
19+
use Illuminate\Support\Facades\Facade as Facade;
1620

1721
class PaystackTest extends PHPUnit_Framework_TestCase
1822
{
23+
protected $paystack;
24+
25+
public function setUp()
26+
{
27+
$this->paystack = m::mock('Unicodeveloper\Paystack\Paystack');
28+
$this->mock = m::mock('GuzzleHttp\Client');
29+
}
30+
31+
public function tearDown()
32+
{
33+
m::close();
34+
}
35+
36+
public function testAllCustomersAreReturned()
37+
{
38+
$array = $this->paystack->shouldReceive('getAllCustomers')->andReturn(['prosper']);
39+
40+
$this->assertEquals('array', gettype(array($array)));
41+
}
42+
43+
public function testAllTransactionsAreReturned()
44+
{
45+
$array = $this->paystack->shouldReceive('getAllTransactions')->andReturn(['transactions']);
46+
47+
$this->assertEquals('array', gettype(array($array)));
48+
}
49+
50+
public function testAllPlansAreReturned()
51+
{
52+
$array = $this->paystack->shouldReceive('getAllPlans')->andReturn(['intermediate-plan']);
53+
54+
$this->assertEquals('array', gettype(array($array)));
55+
}
56+
57+
58+
1959

2060
}

0 commit comments

Comments
 (0)