From b7951062cb302ab84b3d8ce8614452912809d56a Mon Sep 17 00:00:00 2001 From: Amirreza Nasiri Date: Sat, 20 Apr 2024 01:26:43 +0330 Subject: [PATCH] Laravel 11.x Compatibility (#41) * Apply fixes from StyleCI * Laravel 11.x Compatibility (#40) * Bump dependencies for Laravel 11 * Update GitHub Actions for Laravel 11 * Update coverate matrix * Make it Laravel 11 specific * Add testbench version * WIP: Migrating PHPUnit * WIP: Migrate PHPUnit * WIP: Migrate PHPUnit * WIP: Migrate PHPUnit * WIP: Migrate PHPUnit * WIP: Migrate PHPUnit * WIP: Migrate PHPUnit * Use TestCase * WIP: Fix namespaces * Update docs --------- Co-authored-by: Shift * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot Co-authored-by: Shift --- .github/workflows/tests.yml | 34 +++++++--------- composer.json | 28 ++++++++----- docs/_coverpage.md | 2 +- docs/fa/_coverpage.md | 2 +- docs/fa/getting-started.md | 3 +- docs/getting-started.md | 3 +- docs/index.html | 2 +- phpunit.xml.dist | 39 +++++++++---------- src/PendingRequest.php | 2 +- tests/Gateways/IDPay/Provider.php | 3 +- tests/Gateways/Zarinpal/Provider.php | 5 ++- tests/{ => Misc}/CallbackRequestTest.php | 3 +- .../LaravelTomanServiceProviderTest.php | 9 +++-- 13 files changed, 69 insertions(+), 66 deletions(-) rename tests/{ => Misc}/CallbackRequestTest.php (96%) rename tests/{ => Misc}/LaravelTomanServiceProviderTest.php (78%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 81e5441..4ccd1e1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,25 +9,18 @@ on: jobs: linux_tests: runs-on: ubuntu-20.04 + strategy: fail-fast: true matrix: - php: ['8.0', '8.1'] - laravel: ['9.*', '10.*'] + php: ['8.2'] + laravel: ['11.*'] + testbench: ['9.*'] stability: [prefer-lowest, prefer-stable] - exclude: - - laravel: '10.*' - php: '8.0' include: - - laravel: '9.*' - testbench: '7.*' - - laravel: '10.*' - testbench: '8.*' - - php: '8.1' - laravel: '10.*' - testbench: '8.*' - stability: 'prefer-stable' - coverage: '☂ ' + - laravel: 11.* + stability: prefer-stable + coverage: ☂ name: ${{ matrix.coverage }}PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }} - Ubuntu 20.04 @@ -42,7 +35,7 @@ jobs: extensions: dom, curl, libxml, mbstring, zip, pcntl tools: composer:v2 coverage: xdebug - + - name: Set Laravel and Testbench versions uses: nick-invision/retry@v1 with: @@ -59,13 +52,13 @@ jobs: - name: Execute tests continue-on-error: false - run: vendor/bin/phpunit --verbose - if: ${{ !matrix.coverage }} + run: vendor/bin/phpunit + if: '${{ !matrix.coverage }}' - name: Execute tests with coverage continue-on-error: false - run: vendor/bin/phpunit --verbose --coverage-clover coverage.xml - if: ${{ matrix.coverage }} + run: vendor/bin/phpunit --coverage-clover coverage.xml + if: '${{ matrix.coverage }}' - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 @@ -74,5 +67,4 @@ jobs: files: ./coverage.xml path_to_write_report: ./coverage/codecov_report.txt verbose: true - if: ${{ matrix.coverage }} - + if: '${{ matrix.coverage }}' diff --git a/composer.json b/composer.json index b81ca6e..84bf00d 100644 --- a/composer.json +++ b/composer.json @@ -11,20 +11,28 @@ ], "homepage": "https://github.com/evryn/laravel-toman", "keywords": [ - "zarinpal", "زرین پال", - "idpay", "آیدی پی", - "laravel", "laraveltoman", "laravel-toman", - "toman", "payment", "gateway", "درگاه", "پرداخت" + "zarinpal", + "زرین پال", + "idpay", + "آیدی پی", + "laravel", + "laraveltoman", + "laravel-toman", + "toman", + "payment", + "gateway", + "درگاه", + "پرداخت" ], "require": { - "php": "^8.0|^8.1", - "guzzlehttp/guzzle": "^7.2", - "laravel/framework": "^9.0|^10.0" + "php": "^8.2", + "guzzlehttp/guzzle": "^7.8", + "laravel/framework": "^11.0" }, "require-dev": { - "phpunit/phpunit": "^8.0|^9.0", - "mockery/mockery": "^1.3.3", - "orchestra/testbench": "^7.0|^8.0", + "phpunit/phpunit": "^10.5|^11.0", + "mockery/mockery": "^1.6", + "orchestra/testbench": "^9.0", "sempro/phpunit-pretty-print": "^1.0" }, "autoload": { diff --git a/docs/_coverpage.md b/docs/_coverpage.md index 8656db0..40aa0cb 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,6 +1,6 @@ ![logo](_media/logo.png) -# Laravel Toman 3.0 +# Laravel Toman 4.0 > A painless payment handler! diff --git a/docs/fa/_coverpage.md b/docs/fa/_coverpage.md index e31c4bb..9a5e832 100644 --- a/docs/fa/_coverpage.md +++ b/docs/fa/_coverpage.md @@ -1,6 +1,6 @@ ![logo](../_media/logo.png) -# لاراول تومَن 3.0 +# لاراول تومَن 4.0 > درگاه پرداخت - مثل آب خوردن! diff --git a/docs/fa/getting-started.md b/docs/fa/getting-started.md index 2305e47..bc349ec 100644 --- a/docs/fa/getting-started.md +++ b/docs/fa/getting-started.md @@ -4,7 +4,8 @@ | پکیج | فریم‌ورک Laravel | PHP | وضعیت | | ------------- |:-------------:|:-----:| ---:| -| ‎3.\* | ‎10.\*, ‎9.\* | ‎>= 8.0 | فعال 🚀 | +| ‎4.\* | ‎11.\* | ‎>= 8.2 | فعال 🚀 | +| ‎3.\* | ‎10.\*, ‎9.\* | ‎>= 8.0 | | | ‎2.\* | ‎9.\*, ‎8.\*, ‎7.\* | ‎>= 7.3 | | | ‎1.\* | ‎6.\*, ‎5.8.\* | ‎>= 7.2 | | diff --git a/docs/getting-started.md b/docs/getting-started.md index 3834412..8d09a57 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -4,7 +4,8 @@ | Package | Laravel Framework | PHP | Status | | ------------- |:-------------:|:-----:| ---:| -| 3.\* | 10.\*, 9.\* | >= 8.0 | Active 🚀 | +| 4.\* | 11.\* | >= 8.2 | Active 🚀 | +| 3.\* | 10.\*, 9.\* | >= 8.0 | | | 2.\* | 9.\*, 8.\*, 7.\* | >= 7.3 | | | 1.\* | 6.\*, 5.8.\* | >= 7.2 | | diff --git a/docs/index.html b/docs/index.html index 944b81c..1e4c0a9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -55,7 +55,7 @@ loadNavbar: true, fallbackLanguages: ['fa'], coverpage: ['/', '/fa/'], - name: 'Laravel Toman2.0', + name: 'Laravel Toman', repo: 'https://github.com/evryn/laravel-toman/', alias: { '/CHANGELOG': 'https://raw.githubusercontent.com/evryn/laravel-toman/master/CHANGELOG.md', diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f83f8af..663630e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,22 +1,19 @@ - - - - ./tests/ - - - - - src/ - - - + + + + tests/Facades + + + tests/Gateways + + + tests/Misc + + + + + src/ + + + \ No newline at end of file diff --git a/src/PendingRequest.php b/src/PendingRequest.php index d39a3d6..5619783 100644 --- a/src/PendingRequest.php +++ b/src/PendingRequest.php @@ -93,7 +93,7 @@ public function provideForGateway(array $fields): Collection $value = $this->provideAmount(); } - return [$this->getFieldNameForGateway($field) => $value]; + return [$this->getFieldNameForGateway($field) => $value]; })->merge($this->customData); } diff --git a/tests/Gateways/IDPay/Provider.php b/tests/Gateways/IDPay/Provider.php index 4d1a799..ffbb071 100644 --- a/tests/Gateways/IDPay/Provider.php +++ b/tests/Gateways/IDPay/Provider.php @@ -4,8 +4,9 @@ use Evryn\LaravelToman\Gateways\IDPay\Status; use Evryn\LaravelToman\Money; +use Evryn\LaravelToman\Tests\TestCase; -class Provider +final class Provider extends TestCase { public static function endpointProvider() { diff --git a/tests/Gateways/Zarinpal/Provider.php b/tests/Gateways/Zarinpal/Provider.php index 4becac9..3c200ca 100644 --- a/tests/Gateways/Zarinpal/Provider.php +++ b/tests/Gateways/Zarinpal/Provider.php @@ -4,8 +4,9 @@ use Evryn\LaravelToman\Gateways\Zarinpal\Status; use Evryn\LaravelToman\Money; +use Evryn\LaravelToman\Tests\TestCase; -class Provider +final class Provider extends TestCase { public static function endpointProvider() { @@ -15,7 +16,7 @@ public static function endpointProvider() ]; } - public function clientErrorProvider() + public static function clientErrorProvider() { return [ [200, Status::INCOMPLETE_DATA, 'incomplete_data'], // 404 HTTP code is not guaranteed for errors diff --git a/tests/CallbackRequestTest.php b/tests/Misc/CallbackRequestTest.php similarity index 96% rename from tests/CallbackRequestTest.php rename to tests/Misc/CallbackRequestTest.php index de91c67..38beccd 100644 --- a/tests/CallbackRequestTest.php +++ b/tests/Misc/CallbackRequestTest.php @@ -1,12 +1,13 @@ resource_path('lang/vendor/toman/en/zarinpal.php'), - __DIR__.'/../resources/lang/fa/zarinpal.php' => resource_path('lang/vendor/toman/fa/zarinpal.php'), + __DIR__.'/../../resources/lang/en/zarinpal.php' => resource_path('lang/vendor/toman/en/zarinpal.php'), + __DIR__.'/../../resources/lang/fa/zarinpal.php' => resource_path('lang/vendor/toman/fa/zarinpal.php'), ]; foreach (array_values($map) as $dest) {