diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 70dc100..c7f257d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,35 +9,48 @@ on: jobs: test: runs-on: ${{ matrix.os }} + + timeout-minutes: 5 + strategy: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.3, 8.2, 8.1, 8.0] - laravel: [11.*,10.*, 9.*, 8.*] + php: [8.4, 8.3, 8.2, 8.1, 8.0] + laravel: [12.*, 11.*,10.*, 9.*, 8.*] stability: [prefer-lowest, prefer-stable] include: - - laravel: 11.* - testbench: ^9.0 - carbon: ^2.63 - - laravel: 10.* - testbench: ^8.0 - carbon: ^2.63 - - laravel: 9.* - testbench: ^7.0 - carbon: ^2.63 - laravel: 8.* testbench: ^6.23 - carbon: ^2.63 + - laravel: 9.* + testbench: ^7.0 + - laravel: 10.* + testbench: ^8.0 + - laravel: 11.* + testbench: ^9.0 + - laravel: 12.* + testbench: 10.* exclude: + - laravel: 8.* + php: 8.3 + - laravel: 8.* + php: 8.4 + - laravel: 9.* + php: 8.4 - laravel: 10.* php: 8.0 + - laravel: 10.* + php: 8.4 - laravel: 11.* php: 8.0 - laravel: 11.* php: 8.1 - - laravel: 8.* - php: 8.3 + - laravel: 11.* + php: 8.4 + - laravel: 12.* + php: 8.0 + - laravel: 12.* + php: 8.1 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -59,7 +72,7 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:>=2.72" --dev --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: List Installed Dependencies diff --git a/.gitignore b/.gitignore index 818cfd7..1964297 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ build composer.lock coverage phpunit.xml -phpstan.neon testbench.yaml vendor node_modules diff --git a/composer.json b/composer.json index 0e6e7a8..c974a04 100644 --- a/composer.json +++ b/composer.json @@ -36,21 +36,19 @@ "require": { "php": "^8.0|^8.1|^8.2|^8.3", "guzzlehttp/guzzle": "^7.5", - "illuminate/contracts": "^8.50|^9.0|^10.0|^11.0", - "illuminate/support": "^8.50|^9.0|^10.0|^11.0", + "illuminate/contracts": "^8.50|^9.0|^10.0|^11.0|^12.0", + "illuminate/support": "^8.50|^9.0|^10.0|^11.0|^12.0", "spatie/laravel-package-tools": "^1.11" }, "require-dev": { - "laravel/pint": "^1.0", + "laravel/pint": "^1.0|^1.14", "nunomaduro/collision": "^5.3|^6.0|^v7.10|^8.1.1", - "nunomaduro/larastan": "^1.0.4|^2.2", - "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0", - "pestphp/pest": "^1.21|^2.34", - "pestphp/pest-plugin-laravel": "^1.1|^v2.3.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5|^10.4" + "nunomaduro/larastan": "^1.0|^2.0|^3.0", + "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0|^10.0", + "pestphp/pest": "^1.21|^2.0|^3.7", + "pestphp/pest-plugin-laravel": "^1.1|^v2.3.0|^3.0", + "phpstan/extension-installer": "^1.3|^2.0", + "phpstan/phpstan-deprecation-rules": "^1.1|^2.0" }, "autoload": { "files": [ diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a91953b..9f85c1e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -10,5 +10,3 @@ parameters: tmpDir: build/phpstan checkOctaneCompatibility: true checkModelProperties: true - checkMissingIterableValueType: false - diff --git a/src/Events/PaymentWebhookReceivedEvent.php b/src/Events/PaymentWebhookReceivedEvent.php index ad00d50..0ad74df 100644 --- a/src/Events/PaymentWebhookReceivedEvent.php +++ b/src/Events/PaymentWebhookReceivedEvent.php @@ -16,9 +16,7 @@ class PaymentWebhookReceivedEvent * * @return void */ - public function __construct(public $webhookPayload) - { - } + public function __construct(public $webhookPayload) {} /** * Get the channels the event should broadcast on. diff --git a/src/Exceptions/InvalidConfigurationException.php b/src/Exceptions/InvalidConfigurationException.php index 77caf71..95e950b 100644 --- a/src/Exceptions/InvalidConfigurationException.php +++ b/src/Exceptions/InvalidConfigurationException.php @@ -4,6 +4,4 @@ use Exception; -class InvalidConfigurationException extends Exception -{ -} +class InvalidConfigurationException extends Exception {} diff --git a/src/Jobs/ProcessPaymentWebhookJob.php b/src/Jobs/ProcessPaymentWebhookJob.php index 60f5661..b29c58b 100644 --- a/src/Jobs/ProcessPaymentWebhookJob.php +++ b/src/Jobs/ProcessPaymentWebhookJob.php @@ -17,7 +17,5 @@ class ProcessPaymentWebhookJob implements ShouldQueue * * @return void */ - public function __construct(public $webhookPayload) - { - } + public function __construct(public $webhookPayload) {} } diff --git a/src/LaravelMultipaymentGatewaysServiceProvider.php b/src/LaravelMultipaymentGatewaysServiceProvider.php index 062470e..62e789e 100644 --- a/src/LaravelMultipaymentGatewaysServiceProvider.php +++ b/src/LaravelMultipaymentGatewaysServiceProvider.php @@ -63,7 +63,7 @@ private function registerWebHookRoute() private function registerWebHookBindings() { $this->app->scoped(PaymentWebhookConfigRepository::class, function () { - $configRepository = new PaymentWebhookConfigRepository(); + $configRepository = new PaymentWebhookConfigRepository; $webhookConfigs = config('multipayment-gateways.webhooks'); collect($webhookConfigs) diff --git a/src/Models/PaymentWebhookLog.php b/src/Models/PaymentWebhookLog.php index b31bd61..911aeac 100644 --- a/src/Models/PaymentWebhookLog.php +++ b/src/Models/PaymentWebhookLog.php @@ -19,7 +19,6 @@ class PaymentWebhookLog extends Model public static function storePaymentWebhook(PaymentWebhookConfig $config, Request $request, $requestHash): PaymentWebhookLog { - // @phpstan-ignore-next-line return self::create([ 'payment_gateway' => $config->name, 'request_hash' => $requestHash, diff --git a/src/Services/HttpClientWrapper.php b/src/Services/HttpClientWrapper.php index 75afec4..5b194cf 100644 --- a/src/Services/HttpClientWrapper.php +++ b/src/Services/HttpClientWrapper.php @@ -9,9 +9,7 @@ class HttpClientWrapper implements HttpClientWrapperContract { use ConsumesExternalServices; - public function __construct(protected $baseUri, protected $secret) - { - } + public function __construct(protected $baseUri, protected $secret) {} /** * Send a GET request to the payment gateway diff --git a/src/Traits/Paystack/TransactionTrait.php b/src/Traits/Paystack/TransactionTrait.php index 3eb4daf..85c9511 100644 --- a/src/Traits/Paystack/TransactionTrait.php +++ b/src/Traits/Paystack/TransactionTrait.php @@ -90,7 +90,7 @@ private function validateTransaction(): void $this->verifyTransaction(reference: request()->reference ?? request()->trxref); if ($this->getData()['status'] !== 'success') { - throw new PaymentVerificationException(); + throw new PaymentVerificationException; } } diff --git a/tests/Paystack/PaystackTest.php b/tests/Paystack/PaystackTest.php index c20e52d..92a1625 100644 --- a/tests/Paystack/PaystackTest.php +++ b/tests/Paystack/PaystackTest.php @@ -86,41 +86,18 @@ ]); }); -//it('can make fake http request to get list of banks', function () { -// $body = file_get_contents(__DIR__.'/Fixtures/banks.json'); -// -// Http::fake([ -// 'https://api.paystack.co/bank' => Http::response($body, 200), -// ]); -// -// // assert if there is a bank with name "Abbey Mortgage Bank" in the list of banks -//// $body = -// -// -//// expect(json_decode($body, true)['data']) -//// ->toBeArray() -////// ->dd() -//// ->toContain(fn ($bank) => $bank['name'] === 'Abbey Mortgage Bank'); -// -//// expect( -//// collect(json_decode($body, true)['data']) -//// ->where('name', 'Abbey Mortgage Bank') -//// ->isNotEmpty() -//// ) -//// ->toBeTrue(); -// -// -// -//// expect($body) -//// ->toBeString() -//// ->toContain('Abbey Mortgage Bank'); -// -//// expect(json_decode($body, true)) -//// ->toBeArray() -//// ->toHaveKeys([ -//// 'status', -//// 'message', -//// 'data', -//// ]) -//// ->toContain('data'); -//}); +it('can make fake http request to get list of banks', function () { + $body = file_get_contents(__DIR__.'/../Fixtures/banks.json'); + + Http::fake([ + 'https://api.paystack.co/bank' => Http::response($body), + ]); + + expect(json_decode($body, true)) + ->toBeArray() + ->toHaveKeys([ + 'status', + 'message', + 'data', + ]); +});