Skip to content

Commit 89d9db4

Browse files
committed
Added tests
- Fix php version for phpunit in composer.json - Update travis php version to 5.6 - Update phpunit version in composer to 5.3
1 parent d799712 commit 89d9db4

22 files changed

Lines changed: 255 additions & 44 deletions

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: php
22

33
php:
4-
- 5.5
54
- 5.6
65
- 7.0
76
- hhvm
@@ -12,7 +11,7 @@ sudo: false
1211

1312
matrix:
1413
include:
15-
- php: 5.5
14+
- php: 5.6
1615
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
1716

1817
before_script:

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
99
### Changes
1010
- Calls will return an Object of stdClass or throw a Paystack API/cURL error instead of
1111
an array as in version 1
12+
- Root namespace is now Yabacon instead of YabaCon
1213

1314
### Added
1415
- Pages
1516
- Subscriptions
1617
- Use ->fetch to get a single item or call singular form with id/code
17-
- use ->list to get a list of items or call plural form with paging parameters
18+
- Use ->list to get a list of items or call plural form with paging parameters
1819

1920
### Added usage of TLSv1.2
2021
CURL default SSL version TLSv1.2

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
Copyright (c) 2016 YabaCon Valley <yabacon.valley@gmail.com>
3+
Copyright (c) 2016 Yabacon Valley <yabacon.valley@gmail.com>
44

55
> Permission is hereby granted, free of charge, to any person obtaining a copy
66
> of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Download a release version from the [releases page](https://github.com/yabacon/p
3030
Extract, then:
3131
``` php
3232
require 'path/to/src/Paystack.php';
33-
\YabaCon\Paystack::registerAutoloader();
33+
\Yabacon\Paystack::registerAutoloader();
3434
```
3535

3636
## IMPORTANT
@@ -43,7 +43,7 @@ Check [ibrahimlawal/paystack-php-sample](https://github.com/ibrahimlawal/paystac
4343

4444
### Default: Uses curl for requests
4545
``` php
46-
$paystack = new \YabaCon\Paystack('secret_key');
46+
$paystack = new \Yabacon\Paystack('secret_key');
4747

4848
// Make a call to the resource/method
4949
// $paystack->{resource}->{method}();
@@ -87,7 +87,7 @@ $ composer require guzzlehttp/guzzle
8787
**Make calls**
8888
``` php
8989
// create a paystack object
90-
$paystack = new \YabaCon\Paystack('secret_key');
90+
$paystack = new \Yabacon\Paystack('secret_key');
9191
/* IMPORTANT tell it to use guzzle if found (else installing Guzzle will not have had any effect) */
9292
$paystack->useGuzzle();
9393

@@ -141,7 +141,7 @@ If you discover any security related issues, please email yabacon.valley@gmail.c
141141

142142
## Credits
143143

144-
- [YabaCon][link-author]
144+
- [Yabacon][link-author]
145145
- [Issa Jubril](https://github.com/masterp4dev)
146146
- [Ibrahim Lawal](https://github.com/ibrahimlawal)
147147
- [Opeyemi Obembe](https://github.com/kehers) - followed the style he employed in creating the [NodeJS Wrapper](https://github.com/kehers/paystack)

composer.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
{
22
"name": "yabacon/paystack-php",
33
"type": "library",
4-
"description": "helps makes your Paystack API calls",
4+
"description": "Helps make your Paystack API calls giving a stdClass object.",
55
"keywords": [
66
"yabacon",
7-
"paystack-php"
7+
"paystack-php",
8+
"paystack",
9+
"plan",
10+
"page",
11+
"api",
12+
"transaction",
13+
"customer",
14+
"subscription",
15+
"enable",
16+
"disable",
17+
"verify",
18+
"curl"
819
],
920
"homepage": "https://github.com/yabacon/paystack-php",
1021
"license": "MIT",
1122
"authors": [
1223
{
13-
"name": "YabaCon",
24+
"name": "Yabacon",
1425
"email": "yabacon.valley@gmail.com",
1526
"homepage": "https://github.com/yabacon",
1627
"role": "Owner"
@@ -29,28 +40,28 @@
2940
"guzzlehttp/guzzle": "Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services. While not required by Paystack-PHP, installing it will provide you a more object-oriented experience. Also note that when Guzzle is installed, the result from API calls will be a GuzzleHttp\\Psr7\\Response Object"
3041
},
3142
"require-dev": {
32-
"phpunit/phpunit": "^4.*",
43+
"phpunit/phpunit": "~5.3",
3344
"scrutinizer/ocular": "^1.1",
34-
"guzzlehttp/guzzle": "^6.1",
45+
"guzzlehttp/guzzle": "^6.2",
3546
"squizlabs/php_codesniffer": "^2.3",
3647
"vlucas/phpdotenv": "^2.2"
3748
},
3849
"autoload": {
3950
"psr-4": {
40-
"YabaCon\\": "src"
51+
"Yabacon\\": "src/"
4152
}
4253
},
4354
"autoload-dev": {
4455
"psr-4": {
45-
"YabaCon\\Paystack\\Test\\": "tests/"
56+
"Yabacon\\Paystack\\Test\\": "tests/"
4657
}
4758
},
4859
"scripts": {
4960
"test": "phpunit"
5061
},
5162
"extra": {
5263
"branch-alias": {
53-
"dev-master": "2.0.1-dev"
64+
"dev-master": "2.0-dev"
5465
}
5566
}
5667
}

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
processIsolation="false"
1111
stopOnFailure="false">
1212
<testsuites>
13-
<testsuite name="YabaCon Paystack Test Suite">
13+
<testsuite name="Yabacon Paystack Test Suite">
1414
<directory>tests</directory>
1515
</testsuite>
1616
</testsuites>

src/Paystack.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace YabaCon;
3+
namespace Yabacon;
44

5-
use \YabaCon\Paystack\Helpers\Router;
5+
use \Yabacon\Paystack\Helpers\Router;
66

77
/**
88
*
@@ -25,7 +25,6 @@ public function __construct($secret_key)
2525
if (!is_string($secret_key) || !(substr($secret_key, 0, 3)==='sk_')) {
2626
// Should never get here
2727
throw new \InvalidArgumentException('A Valid Paystack Secret Key must start with \'sk_\'.');
28-
2928
}
3029
$this->secret_key = $secret_key;
3130
$this->routes = $this->definedRoutes();
@@ -41,14 +40,14 @@ public function useGuzzle()
4140

4241
/**
4342
* definedRoutes
44-
* gets routes defined in the YabaCon\Paystack\Routes namespace
43+
* gets routes defined in the Yabacon\Paystack\Routes namespace
4544
* since we are using PSR-4. It is safe to assume that all php
4645
* files in the folder are names of the classes.
4746
*
4847
* @return the list of defined Routes
4948
*
5049
* @access private
51-
* @see YabaCon\Paystack\Routes\Router
50+
* @see Yabacon\Paystack\Routes\Router
5251
* @since 1.0
5352
*/
5453
private function definedRoutes()
@@ -67,14 +66,14 @@ private function definedRoutes()
6766
* Magic Method for fetch on routes
6867
*
6968
* @param $method - a string whose title case is a class in the
70-
* YabaCon\Paystack\Routes namespace implementing
71-
* YabaCon\Paystack\Contracts\RouteInterface
69+
* Yabacon\Paystack\Routes namespace implementing
70+
* Yabacon\Paystack\Contracts\RouteInterface
7271
* @param $args - arguments sent to the magic method
7372
*
7473
* @return the result of calling /{route}/get on the api
7574
*
7675
* @access public
77-
* @see YabaCon\Paystack\Routes\Router
76+
* @see Yabacon\Paystack\Routes\Router
7877
* @since 1.0
7978
*/
8079
public function __call($method, $args)
@@ -124,7 +123,7 @@ public static function registerAutoloader()
124123
*/
125124
function ($class_name) {
126125
$file = dirname(__FILE__) . DIRECTORY_SEPARATOR;
127-
$file .= str_replace([ 'YabaCon\\', '\\' ], ['', DIRECTORY_SEPARATOR ], $class_name) . '.php';
126+
$file .= str_replace([ 'Yabacon\\', '\\' ], ['', DIRECTORY_SEPARATOR ], $class_name) . '.php';
128127
include_once $file;
129128
}
130129
);

src/Paystack/Contracts/RouteInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* A Route
44
*/
55

6-
namespace YabaCon\Paystack\Contracts;
6+
namespace Yabacon\Paystack\Contracts;
77

88
interface RouteInterface
99
{

src/Paystack/Helpers/Router.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
namespace YabaCon\Paystack\Helpers;
3+
namespace Yabacon\Paystack\Helpers;
44

55
use \Closure;
6-
use \YabaCon\Paystack\Contracts\RouteInterface;
6+
use \Yabacon\Paystack\Contracts\RouteInterface;
77

88
/**
99
* Router
@@ -141,7 +141,6 @@ private function callViaCurl($interface, $payload = [ ], $sentargs = [ ])
141141
}
142142
}
143143
return $response;
144-
145144
} else {
146145
//open connection
147146

@@ -224,16 +223,19 @@ public function __call($methd, $sentargs)
224223
* A magic resource object that can make method calls to API
225224
*
226225
* @param $route
227-
* @param $paystackObj - A YabaCon\Paystack Object
226+
* @param $paystackObj - A Yabacon\Paystack Object
228227
*/
229228
public function __construct($route, $paystackObj)
230229
{
231230
$this->route = strtolower($route);
232-
$this->route_class = 'YabaCon\\Paystack\\Routes\\' . ucwords($route);
231+
$this->route_class = 'Yabacon\\Paystack\\Routes\\' . ucwords($route);
233232
$this->secret_key = $paystackObj->secret_key;
234233
$this->use_guzzle = $paystackObj->use_guzzle;
235234

236235
$mets = get_class_methods($this->route_class);
236+
if (empty($mets)) {
237+
throw new \InvalidArgumentException('Class "' . $this->route . '" does not exist.');
238+
}
237239
// add methods to this object per method, except root
238240
foreach ($mets as $mtd) {
239241
if ($mtd === 'root') {

src/Paystack/Routes/Customer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace YabaCon\Paystack\Routes;
3+
namespace Yabacon\Paystack\Routes;
44

5-
use YabaCon\Paystack\Contracts\RouteInterface;
5+
use Yabacon\Paystack\Contracts\RouteInterface;
66

77
/**
88
* Customer

0 commit comments

Comments
 (0)