From 7af900702722614fe436ec34e676bfed89047714 Mon Sep 17 00:00:00 2001 From: Olatunbosun Egberinde Date: Fri, 4 Oct 2019 21:56:22 +0100 Subject: [PATCH] Update Failing Tests and update PR/3 --- composer.json | 2 +- composer.lock | 28 ++++++++++++++-------------- src/App/PaystackApplication.php | 3 ++- src/Client.php | 2 +- test/ClientTest.php | 9 +++++---- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index d398315..4e80ad3 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "minimum-stability": "stable", "require": { - "php": "^7.1.3", + "php": "^7.1.3|^7.2", "psr/http-message": "^1.0", "psr/cache": "^1.0", "php-http/httplug": "1.0.0|2.0.0", diff --git a/composer.lock b/composer.lock index cacf3c1..c19605c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3f20db0ab5abd6c432b971435ed80073", + "content-hash": "c92b66d9328e062374537f2006a57fc8", "packages": [ { "name": "clue/stream-filter", @@ -514,16 +514,16 @@ }, { "name": "nesbot/carbon", - "version": "2.24.0", + "version": "2.25.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "934459c5ac0658bc765ad1e53512c7c77adcac29" + "reference": "b70da677101cca7b584c7489770d2677c2733593" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/934459c5ac0658bc765ad1e53512c7c77adcac29", - "reference": "934459c5ac0658bc765ad1e53512c7c77adcac29", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/b70da677101cca7b584c7489770d2677c2733593", + "reference": "b70da677101cca7b584c7489770d2677c2733593", "shasum": "" }, "require": { @@ -570,14 +570,14 @@ "homepage": "http://github.com/kylekatarnls" } ], - "description": "A API extension for DateTime that supports 281 different languages.", + "description": "An API extension for DateTime that supports 281 different languages.", "homepage": "http://carbon.nesbot.com", "keywords": [ "date", "datetime", "time" ], - "time": "2019-08-31T16:37:55+00:00" + "time": "2019-09-30T16:22:22+00:00" }, { "name": "php-http/cache-plugin", @@ -2253,22 +2253,22 @@ }, { "name": "phpspec/prophecy", - "version": "1.8.1", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, @@ -2312,7 +2312,7 @@ "spy", "stub" ], - "time": "2019-06-13T12:50:23+00:00" + "time": "2019-10-03T11:07:50+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3421,7 +3421,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": "^7.1.3" + "php": "^7.1.3|^7.2" }, "platform-dev": [] } diff --git a/src/App/PaystackApplication.php b/src/App/PaystackApplication.php index 53454a9..c5d8dde 100644 --- a/src/App/PaystackApplication.php +++ b/src/App/PaystackApplication.php @@ -24,6 +24,7 @@ use Http\Message\RequestFactory; use Http\Message\StreamFactory; use Illuminate\Container\Container; +use Illuminate\Contracts\Container\BindingResolutionException; use ReflectionException; use Xeviant\Paystack\Client; use Xeviant\Paystack\Config as PaystackConfig; @@ -192,7 +193,7 @@ public function makeApi(string $apiName): ApiInterface { try { return $this->make($apiName); - } catch (ReflectionException $e) { + } catch (BindingResolutionException $e) { throw new InvalidArgumentException(sprintf('Undefined API called: "%s', $apiName)); } } diff --git a/src/Client.php b/src/Client.php index e393925..4dff801 100644 --- a/src/Client.php +++ b/src/Client.php @@ -138,7 +138,7 @@ public function api($name): ApiInterface try { return $this->app->makeApi($name); } catch (InvalidArgumentException $e) { - throw new InvalidArgumentException($e->getMessage()); + throw $e; } } diff --git a/test/ClientTest.php b/test/ClientTest.php index d19aebb..fec3bb4 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -3,6 +3,7 @@ namespace Xeviant\Paystack\Tests; use Http\Client\HttpClient; +use Illuminate\Contracts\Container\BindingResolutionException; use Xeviant\Paystack\Api\Balance; use Xeviant\Paystack\Api\Bank; use Xeviant\Paystack\Api\BulkCharges; @@ -21,6 +22,8 @@ use Xeviant\Paystack\Api\TransferRecipients; use Xeviant\Paystack\Api\Transfers; use Xeviant\Paystack\Client; +use Xeviant\Paystack\Exception\BadMethodCallException; +use Xeviant\Paystack\Exception\InvalidArgumentException; final class ClientTest extends TestCase { @@ -78,24 +81,22 @@ public function shouldMagicallyGetApiInstance($apiName, $class) /** * @test - * @expectedException \Xeviant\Paystack\Exception\InvalidArgumentException - * - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function shouldNotBeAbleToGetApiInstanceThatDoesntExits() { + $this->expectException(InvalidArgumentException::class); $client = new Client(); $client->api('this_doesnt_exist'); } /** * @test - * @expectedException \Xeviant\Paystack\Exception\BadMethodCallException * * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function shouldNotBeAbleToGetMagicApiInstanceThatDoesntExits() { + $this->expectException(BadMethodCallException::class); $client = new Client(); $client->doesNotExist(); }