|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Binkode\Paystack\Tests; |
| 4 | + |
| 5 | +use Binkode\Paystack\Facades\Paystack as PaystackFacade; |
| 6 | +use Binkode\Paystack\Http\Middleware\DisabledRoute; |
| 7 | +use Binkode\Paystack\Http\Middleware\ValidatePaystackHook; |
| 8 | +use Binkode\Paystack\Paystack; |
| 9 | +use Binkode\Paystack\PaystackConfig; |
| 10 | + |
| 11 | +class ServiceProviderTest extends TestCase |
| 12 | +{ |
| 13 | + public function test_paystack_service_is_bound_as_singleton(): void |
| 14 | + { |
| 15 | + $first = $this->app->make('paystack'); |
| 16 | + $second = $this->app->make('paystack'); |
| 17 | + |
| 18 | + $this->assertInstanceOf(Paystack::class, $first); |
| 19 | + $this->assertSame($first, $second); |
| 20 | + } |
| 21 | + |
| 22 | + public function test_facade_resolves_the_paystack_singleton(): void |
| 23 | + { |
| 24 | + $resolved = PaystackFacade::getFacadeRoot(); |
| 25 | + |
| 26 | + $this->assertInstanceOf(Paystack::class, $resolved); |
| 27 | + $this->assertSame($this->app->make('paystack'), $resolved); |
| 28 | + } |
| 29 | + |
| 30 | + public function test_default_config_values_are_merged_and_accessible(): void |
| 31 | + { |
| 32 | + $this->assertSame('https://api.paystack.co', config('paystack.url')); |
| 33 | + $this->assertSame('api', config('paystack.route.prefix')); |
| 34 | + $this->assertSame(['paystack_route_disabled', 'api'], config('paystack.route.middleware')); |
| 35 | + $this->assertSame(config('paystack.route.prefix'), PaystackConfig::config('route.prefix')); |
| 36 | + } |
| 37 | + |
| 38 | + public function test_route_middlewares_are_registered(): void |
| 39 | + { |
| 40 | + $middlewares = $this->app['router']->getMiddleware(); |
| 41 | + |
| 42 | + $this->assertArrayHasKey('paystack_route_disabled', $middlewares); |
| 43 | + $this->assertSame(DisabledRoute::class, $middlewares['paystack_route_disabled']); |
| 44 | + |
| 45 | + $this->assertArrayHasKey('validate_paystack_hook', $middlewares); |
| 46 | + $this->assertSame(ValidatePaystackHook::class, $middlewares['validate_paystack_hook']); |
| 47 | + } |
| 48 | +} |
0 commit comments