From e0716124bcde1b3ad6fef70967e1d8d646fb9cd0 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Mon, 10 Apr 2023 17:22:10 +0530 Subject: [PATCH 01/46] feat: Test coverage --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..1b5ba3f3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: CI +on: + push: + branches: + - master + tags: + - v[0-9]+.[0-9]+.[0-9]+* + pull_request: + branches: + - master +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up php 8.0 + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + - name: Install dependencies + run: composer self-update && composer install && composer dump-autoload + - name: Run tests and collect coverage + run: vendor/bin/phpunit --coverage-clover coverage.xml . + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + From d18200477812fb31c85ffe74a692c1046aa025c0 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Mon, 10 Apr 2023 17:45:09 +0530 Subject: [PATCH 02/46] add coverage script --- tests/CoverageTest.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/CoverageTest.php diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php new file mode 100644 index 00000000..27c070f3 --- /dev/null +++ b/tests/CoverageTest.php @@ -0,0 +1,37 @@ +setUp(); + $addon->testCreateAddon(); + $addon->testFetchSubscriptionLink(); + $addon->testFetchAllAddon(); + } + + /** + * @covers \Razorpay\Tests\CustomerTest::testCreateCustomer + * @covers \Razorpay\Tests\CustomerTest::testEditCustomer + * @covers \Razorpay\Tests\CustomerTest::testFetchAll + * @covers \Razorpay\Tests\CustomerTest::testFetchCustomer + */ + public function testCustomerCoverage(){ + $customer = new CustomerTest(); + $customer->setUp(); + $customer->testCreateCustomer(); + $customer->testEditCustomer(); + $customer->testFetchAll(); + $customer->testFetchCustomer(); + } + +} \ No newline at end of file From bf3a8d856362aba11493c9ca73c009cadc5b7b7f Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Mon, 10 Apr 2023 17:50:08 +0530 Subject: [PATCH 03/46] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b5ba3f3..e23650a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: - name: Install dependencies run: composer self-update && composer install && composer dump-autoload - name: Run tests and collect coverage - run: vendor/bin/phpunit --coverage-clover coverage.xml . + run: vendor/bin/phpunit ./tests/CoverageTest.php --coverage-clover coverage.xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 From 7fb2706b7c0c22784c7e8ca11ee05da61daa5259 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Mon, 10 Apr 2023 18:29:31 +0530 Subject: [PATCH 04/46] Update ci.yml --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e23650a4..4cbbbe7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,8 @@ jobs: run: composer self-update && composer install && composer dump-autoload - name: Run tests and collect coverage run: vendor/bin/phpunit ./tests/CoverageTest.php --coverage-clover coverage.xml + env: + RAZORPAY_API_KEY: ${{ secrets.RAZORPAY_API_KEY }} + RAZORPAY_API_SECRET: ${{ secrets.RAZORPAY_API_SECRET }} - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 - From 1ef9752d966629609b381be9b0d324d318416628 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Mon, 10 Apr 2023 19:14:52 +0530 Subject: [PATCH 05/46] Update TestCase.php --- tests/TestCase.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index affe7483..8e8889e0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,14 +6,18 @@ use Razorpay\Api\Request; use PHPUnit\Framework\TestCase as PhpUnitTest; +$key = $_ENV["RAZORPAY_API_KEY"]; +$secret = $_ENV["RAZORPAY_API_KEY"]; + + class TestCase extends PhpUnitTest { public function setUp(): void { - $apiKey = ""; - $apiSecret = ""; + $apiKey = $key; + $apiSecret = $secret; $this->api = new Api( $apiKey, $apiSecret); } -} \ No newline at end of file +} From 97c659b0a45ac7f74a0215b9aa3d9978d65c8a29 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 10:54:48 +0530 Subject: [PATCH 06/46] Update TestCase.php --- tests/TestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 8e8889e0..ee6fc7ce 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase as PhpUnitTest; $key = $_ENV["RAZORPAY_API_KEY"]; -$secret = $_ENV["RAZORPAY_API_KEY"]; +$secret = $_ENV["RAZORPAY_API_SECRET"]; class TestCase extends PhpUnitTest From ce3811ce32957140a356486d6c0331329e9934fa Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:47:49 +0530 Subject: [PATCH 07/46] Update ci.yml --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cbbbe7b..81a243a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,9 @@ jobs: run: runs-on: ubuntu-latest steps: + - name: Set env variables + echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> .env + echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> .env - name: Checkout uses: actions/checkout@v2 - name: Set up php 8.0 From b7c0811afaff0110b73d5c008bc081b814efdf2a Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:49:13 +0530 Subject: [PATCH 08/46] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81a243a8..3909b447 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: with: php-version: '8.0' - name: Install dependencies - run: composer self-update && composer install && composer dump-autoload + run: composer self-update && composer install && composer require vlucas/phpdotenv && composer dump-autoload - name: Run tests and collect coverage run: vendor/bin/phpunit ./tests/CoverageTest.php --coverage-clover coverage.xml env: From 4d28312765fb34d8589321a27d34bec46dc30bad Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:50:26 +0530 Subject: [PATCH 09/46] Update TestCase.php --- tests/TestCase.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/TestCase.php b/tests/TestCase.php index ee6fc7ce..fcd0ebd2 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,10 +1,15 @@ load(); $key = $_ENV["RAZORPAY_API_KEY"]; $secret = $_ENV["RAZORPAY_API_SECRET"]; From c334d605186891bbe90a28c81163d7ed7f4ad46f Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:56:35 +0530 Subject: [PATCH 10/46] Update ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3909b447..06a35f44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: - name: Set env variables echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> .env echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> .env + cat .env - name: Checkout uses: actions/checkout@v2 - name: Set up php 8.0 From 71bac3439d8d581c4f7904b2bcf0e1ad20003ceb Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:58:39 +0530 Subject: [PATCH 11/46] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06a35f44..07d1e3de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Set env variables + run: | echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> .env echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> .env - cat .env - name: Checkout uses: actions/checkout@v2 - name: Set up php 8.0 From 62cc76da18bbcf7a805a42c5bcd7a76733ec9107 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:26:23 +0530 Subject: [PATCH 12/46] Update TestCase.php --- tests/TestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index fcd0ebd2..a18071e0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,7 +1,7 @@ Date: Tue, 11 Apr 2023 13:29:16 +0530 Subject: [PATCH 13/46] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07d1e3de..bc35f69e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,8 @@ jobs: steps: - name: Set env variables run: | - echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> .env - echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> .env + echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> tests/.env + echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> tests/.env - name: Checkout uses: actions/checkout@v2 - name: Set up php 8.0 From f62db104dd17893409c482d2d6fda23ac78c27be Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:34:20 +0530 Subject: [PATCH 14/46] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc35f69e..416db757 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,8 @@ jobs: steps: - name: Set env variables run: | - echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> tests/.env - echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> tests/.env + echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> ${{ github.workspace }}/razorpay-php/tests/.env + echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> ${{ github.workspace }}/razorpay-php/tests/.env - name: Checkout uses: actions/checkout@v2 - name: Set up php 8.0 From 1046a50197a7d43039a6b6b9a325f5e9c2f5e558 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:36:25 +0530 Subject: [PATCH 15/46] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 416db757..6dafddb7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,8 @@ jobs: steps: - name: Set env variables run: | - echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> ${{ github.workspace }}/razorpay-php/tests/.env - echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> ${{ github.workspace }}/razorpay-php/tests/.env + echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> ${{ github.workspace }}/tests/.env + echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> ${{ github.workspace }}/tests/.env - name: Checkout uses: actions/checkout@v2 - name: Set up php 8.0 From 93cff686b4dbc9566dc1f6db76c671c8be56b5f1 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:39:14 +0530 Subject: [PATCH 16/46] Update ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6dafddb7..a258a3bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: run: | echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> ${{ github.workspace }}/tests/.env echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> ${{ github.workspace }}/tests/.env + cat ${{ github.workspace }}/tests/.env - name: Checkout uses: actions/checkout@v2 - name: Set up php 8.0 From 0cf74345b8151918b4b15fb4a0faf8e366506bd7 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:43:53 +0530 Subject: [PATCH 17/46] Update ci.yml --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a258a3bf..13be48d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,9 @@ jobs: run: runs-on: ubuntu-latest steps: + - name: List files + run | + ls -R ${{ github.workspace }}/tests/ - name: Set env variables run: | echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> ${{ github.workspace }}/tests/.env From 83569f29019d6c7ac990c69f6a4f3969db621fda Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:45:09 +0530 Subject: [PATCH 18/46] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13be48d2..b99c574c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,8 @@ jobs: runs-on: ubuntu-latest steps: - name: List files - run | - ls -R ${{ github.workspace }}/tests/ + run: | + ls -R ${{ github.workspace }}/tests/ - name: Set env variables run: | echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> ${{ github.workspace }}/tests/.env From 6880b74409103933881803b455c2547ea2b44020 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:46:38 +0530 Subject: [PATCH 19/46] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b99c574c..08329752 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: steps: - name: List files run: | - ls -R ${{ github.workspace }}/tests/ + ls -R ${{ github.workspace }} - name: Set env variables run: | echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> ${{ github.workspace }}/tests/.env From f7b66993827b6b4a0ec7d440e3bc714b20e4963a Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:48:52 +0530 Subject: [PATCH 20/46] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08329752..1fd94c05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: steps: - name: List files run: | - ls -R ${{ github.workspace }} + ls ${{ github.workspace }} - name: Set env variables run: | echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> ${{ github.workspace }}/tests/.env From 4077921812706c6d6dd070408e1357563912174e Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:52:59 +0530 Subject: [PATCH 21/46] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fd94c05..ce6e1ded 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,8 @@ jobs: ls ${{ github.workspace }} - name: Set env variables run: | - echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> ${{ github.workspace }}/tests/.env - echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> ${{ github.workspace }}/tests/.env + echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> .env + echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> .env cat ${{ github.workspace }}/tests/.env - name: Checkout uses: actions/checkout@v2 From 064b89bb2ddb3b47772510d9ddb2ff56b9a9fba9 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 14:00:38 +0530 Subject: [PATCH 22/46] Create .env --- .env | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 00000000..6c531fbb --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }} +RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }} From f14331eb5be074b54c65e864068c255a5a11f9aa Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 14:01:42 +0530 Subject: [PATCH 23/46] Update ci.yml --- .github/workflows/ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce6e1ded..5f837c72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,14 +12,6 @@ jobs: run: runs-on: ubuntu-latest steps: - - name: List files - run: | - ls ${{ github.workspace }} - - name: Set env variables - run: | - echo "RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }}" >> .env - echo "RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }}" >> .env - cat ${{ github.workspace }}/tests/.env - name: Checkout uses: actions/checkout@v2 - name: Set up php 8.0 From 24fec60b853f7ab8ae32c8586f2e037d1d28fef5 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 19:09:11 +0530 Subject: [PATCH 24/46] Update ci.yml --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f837c72..c476fa65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,12 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: '8.0' + - name: 'Create env file' + run: | + touch ${{ github.workspace }}/tests/.env + echo RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }} >> ${{ github.workspace }}/tests/.env + echo RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }} >> ${{ github.workspace }}/tests/.env + cat ${{ github.workspace }}/tests/.env - name: Install dependencies run: composer self-update && composer install && composer require vlucas/phpdotenv && composer dump-autoload - name: Run tests and collect coverage From 794f9d5fc6ba3c262b0ab133678ad732b108fd51 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 19:14:23 +0530 Subject: [PATCH 25/46] Update TestCase.php --- tests/TestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index a18071e0..5701d154 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -20,8 +20,8 @@ class TestCase extends PhpUnitTest public function setUp(): void { - $apiKey = $key; - $apiSecret = $secret; + $key = $_ENV["RAZORPAY_API_KEY"]; + $secret = $_ENV["RAZORPAY_API_SECRET"]; $this->api = new Api( $apiKey, $apiSecret); } From 55e8cfbcb32b3c7525a999395011db1c050e331c Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 19:16:40 +0530 Subject: [PATCH 26/46] Delete .env --- .env | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 6c531fbb..00000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }} -RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }} From 04846b52a69a86691058b05ca33f0da38dccf74a Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 19:20:03 +0530 Subject: [PATCH 27/46] Update TestCase.php --- tests/TestCase.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 5701d154..fcd6697e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -11,17 +11,14 @@ $dotenv = Dotenv::createImmutable(__DIR__); $dotenv->load(); -$key = $_ENV["RAZORPAY_API_KEY"]; -$secret = $_ENV["RAZORPAY_API_SECRET"]; - class TestCase extends PhpUnitTest { public function setUp(): void { - $key = $_ENV["RAZORPAY_API_KEY"]; - $secret = $_ENV["RAZORPAY_API_SECRET"]; + $key = getenv("RAZORPAY_API_KEY"); + $secret = getenv("RAZORPAY_API_SECRET"); $this->api = new Api( $apiKey, $apiSecret); } From 4f2a2d72ebc6db066e9412cbc059456f973cf07d Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Apr 2023 19:21:40 +0530 Subject: [PATCH 28/46] Update TestCase.php --- tests/TestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index fcd6697e..fb6b7f84 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -17,8 +17,8 @@ class TestCase extends PhpUnitTest public function setUp(): void { - $key = getenv("RAZORPAY_API_KEY"); - $secret = getenv("RAZORPAY_API_SECRET"); + $apiKey = getenv("RAZORPAY_API_KEY"); + $apiSecret = getenv("RAZORPAY_API_SECRET"); $this->api = new Api( $apiKey, $apiSecret); } From 770c432f4d76aa512b35555279222860fa8ad9e9 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Wed, 12 Apr 2023 11:46:06 +0530 Subject: [PATCH 29/46] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c476fa65..dc8c990e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: Install dependencies run: composer self-update && composer install && composer require vlucas/phpdotenv && composer dump-autoload - name: Run tests and collect coverage - run: vendor/bin/phpunit ./tests/CoverageTest.php --coverage-clover coverage.xml + run: vendor/bin/phpunit ./tests/CoverageTest.php --coverage-clover coverage.xml . env: RAZORPAY_API_KEY: ${{ secrets.RAZORPAY_API_KEY }} RAZORPAY_API_SECRET: ${{ secrets.RAZORPAY_API_SECRET }} From 483ec08d4ec762e29a48e8e94e0ccc14f7ecb94a Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Wed, 12 Apr 2023 12:14:20 +0530 Subject: [PATCH 30/46] update cases --- tests/CoverageTest.php | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index 27c070f3..32db979e 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -7,23 +7,10 @@ class CoverageTest extends TestCase { /** - * @covers \Razorpay\Tests\AddonTest::testCreateAddon - * @covers \Razorpay\Tests\AddonTest::testFetchSubscriptionLink - * @covers \Razorpay\Tests\AddonTest::testFetchAllAddon - */ - public function testAddonCoverage(){ - $addon = new AddonTest(); - $addon->setUp(); - $addon->testCreateAddon(); - $addon->testFetchSubscriptionLink(); - $addon->testFetchAllAddon(); - } - - /** - * @covers \Razorpay\Tests\CustomerTest::testCreateCustomer - * @covers \Razorpay\Tests\CustomerTest::testEditCustomer - * @covers \Razorpay\Tests\CustomerTest::testFetchAll - * @covers \Razorpay\Tests\CustomerTest::testFetchCustomer + * @covers \Razorpay\Api\CustomerTest::create + * @covers \Razorpay\Api\CustomerTest::edit + * @covers \Razorpay\Api\CustomerTest::all + * @covers \Razorpay\Api\CustomerTest::fetch */ public function testCustomerCoverage(){ $customer = new CustomerTest(); From 26b84b5251d79fbc90927f061b971b8f888fb128 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Wed, 12 Apr 2023 12:25:21 +0530 Subject: [PATCH 31/46] update cases --- tests/CoverageTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index 32db979e..1bfab488 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -7,10 +7,10 @@ class CoverageTest extends TestCase { /** - * @covers \Razorpay\Api\CustomerTest::create - * @covers \Razorpay\Api\CustomerTest::edit - * @covers \Razorpay\Api\CustomerTest::all - * @covers \Razorpay\Api\CustomerTest::fetch + * @covers \Razorpay\Api\Customer::create + * @covers \Razorpay\Api\Customer::edit + * @covers \Razorpay\Api\Customer::all + * @covers \Razorpay\Api\Customer::fetch */ public function testCustomerCoverage(){ $customer = new CustomerTest(); From 0013ff9d8b96394273d91795342d4d09d47ded95 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Wed, 12 Apr 2023 13:36:31 +0530 Subject: [PATCH 32/46] update cases --- tests/CardTest.php | 30 +++++++++++++++++++++++++ tests/CoverageTest.php | 50 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tests/CardTest.php diff --git a/tests/CardTest.php b/tests/CardTest.php new file mode 100644 index 00000000..169d3af6 --- /dev/null +++ b/tests/CardTest.php @@ -0,0 +1,30 @@ +api->card->fetch($this->cardId); + + $this->assertTrue(in_array($this->cardId, $data->toArray())); + } + +} \ No newline at end of file diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index 1bfab488..c54c41f8 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -6,6 +6,17 @@ class CoverageTest extends TestCase { + /** + * @covers \Razorpay\Api\Addon::fetch + * @covers \Razorpay\Api\Addon::fetchAll + */ + public function testAddonCoverage(){ + $addon = new AddonTest(); + $addon->setUp(); + $addon->testFetchSubscriptionLink(); + $addon->testFetchAllAddon(); + } + /** * @covers \Razorpay\Api\Customer::create * @covers \Razorpay\Api\Customer::edit @@ -21,4 +32,43 @@ public function testCustomerCoverage(){ $customer->testFetchCustomer(); } + /** + * @covers \Razorpay\Api\Card::fetch + */ + public function testCardCoverage(){ + $card = new CardTest(); + $card->setup(); + $card->testFetchCard(); + } + + /** + * @covers \Razorpay\Api\FundAccount::create + * @covers \Razorpay\Api\FundAccount::all + */ + public function testFundCoverage(){ + $fund = new FundTest(); + $fund->setup(); + $fund->testCreateFundAccount(); + $fund->testCreateOrder(); + } + + /** + * @covers \Razorpay\Api\Invoice::create + * @covers \Razorpay\Api\Invoice::all + * @covers \Razorpay\Api\Invoice::edit + * @covers \Razorpay\Api\Invoice::notifyBy + * @covers \Razorpay\Api\Invoice::delete + * @covers \Razorpay\Api\Invoice::cancel + * @uses \Razorpay\Api\Invoice::fetch + */ + public function testInvoiceCoverage(){ + $invoice = new InvoiceTest(); + $invoice->setup(); + $invoice->testCreateInvoice(); + $invoice->testFetchAllInvoice(); + $invoice->testUpdateInvoice(); + $invoice->testInvoiceIssue(); + $invoice->testDeleteInvoice(); + $invoice->testCancelInvoice(); + } } \ No newline at end of file From 2f8db1992472c2998e2a69550cdf571fb2e3deff Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Wed, 12 Apr 2023 19:37:25 +0530 Subject: [PATCH 33/46] update cases and params --- tests/CoverageTest.php | 137 +++++++++++++++++++++++++++++++++----- tests/PaymentLinkTest.php | 26 +++++--- tests/QrCodeTest.php | 2 +- tests/RefundTest.php | 6 +- 4 files changed, 139 insertions(+), 32 deletions(-) diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index c54c41f8..78364711 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -52,23 +52,124 @@ public function testFundCoverage(){ $fund->testCreateOrder(); } + /** + * @covers \Razorpay\Api\Invoice::create + * @covers \Razorpay\Api\Invoice::all + * @covers \Razorpay\Api\Invoice::edit + * @covers \Razorpay\Api\Invoice::notifyBy + * @covers \Razorpay\Api\Invoice::delete + * @covers \Razorpay\Api\Invoice::cancel + * @uses \Razorpay\Api\Invoice::fetch + */ + public function testInvoiceCoverage(){ + $invoice = new InvoiceTest(); + $invoice->setup(); + $invoice->testCreateInvoice(); + $invoice->testFetchAllInvoice(); + $invoice->testUpdateInvoice(); + $invoice->testInvoiceIssue(); + $invoice->testDeleteInvoice(); + $invoice->testCancelInvoice(); + } + + /** + * @covers \Razorpay\Api\Item::create + * @covers \Razorpay\Api\Item::fetch + * @covers \Razorpay\Api\Item::edit + * @covers \Razorpay\Api\Item::all + * @covers \Razorpay\Api\Item::delete + */ + public function testItemCoverage(){ + $item = new ItemTest(); + $item->setup(); + $item->testcreate(); + $item->testAllItems(); + $item->testfetchItem(); + $item->testUpdate(); + $item->testDelete(); + } + + /** + * @covers \Razorpay\Api\Order::create + * @covers \Razorpay\Api\Order::all + * @covers \Razorpay\Api\Order::fetch + * @covers \Razorpay\Api\Order::edit + */ + public function testOrderCoverage(){ + $order = new OrdersTest(); + $order->setup(); + $order->testCreateOrder(); + $order->testAllOrders(); + $order->testFetchOrder(); + $order->testUpdateOrder(); + } + + /** + * @covers \Razorpay\Api\Payment::fetch + * @covers \Razorpay\Api\Payment::all + * @covers \Razorpay\Api\Payment::edit + * @covers \Razorpay\Api\Order::payments + * @covers \Razorpay\Api\Payment::fetchCardDetails + * @covers \Razorpay\Api\Payment::fetchPaymentDowntime + * @covers \Razorpay\Api\Payment::fetchPaymentDowntimeById + */ + public function testPaymentCoverage(){ + $order = new PaymentTest(); + $order->setup(); + $order->testFetchPayment(); + $order->testFetchAllPayment(); + $order->testUpdatePayment(); + $order->testFetchOrderPayment(); + $order->testFetchCardWithPaymentId(); + $order->testfetchPaymentDowntime(); + $order->testfetchPaymentDowntimeById(); + } + /** - * @covers \Razorpay\Api\Invoice::create - * @covers \Razorpay\Api\Invoice::all - * @covers \Razorpay\Api\Invoice::edit - * @covers \Razorpay\Api\Invoice::notifyBy - * @covers \Razorpay\Api\Invoice::delete - * @covers \Razorpay\Api\Invoice::cancel - * @uses \Razorpay\Api\Invoice::fetch - */ - public function testInvoiceCoverage(){ - $invoice = new InvoiceTest(); - $invoice->setup(); - $invoice->testCreateInvoice(); - $invoice->testFetchAllInvoice(); - $invoice->testUpdateInvoice(); - $invoice->testInvoiceIssue(); - $invoice->testDeleteInvoice(); - $invoice->testCancelInvoice(); - } + * @covers \Razorpay\Api\PaymentLink::create + * @covers \Razorpay\Api\PaymentLink::fetch + * @covers \Razorpay\Api\PaymentLink::all + * @covers \Razorpay\Api\PaymentLink::cancel + * @covers \Razorpay\Api\PaymentLink::edit + * @covers \Razorpay\Api\PaymentLink::notifyBy + */ + public function testPaymentlinkCoverage(){ + $paymentlink = new PaymentLinkTest(); + $paymentlink->setup(); + $paymentlink->testCreatePaymentLink(); + $paymentlink->testFetchRefund(); + $paymentlink->testFetchAllMutlipleRefund(); + $paymentlink->testCancelPaymentLink(); + $paymentlink->testUpdatePaymentLink(); + $paymentlink->testSendNotification(); + } + + /** + * @covers \Razorpay\Api\QrCode::create + * @covers \Razorpay\Api\QrCode::fetch + * @covers \Razorpay\Api\QrCode::close + * @covers \Razorpay\Api\QrCode::all + * @covers \Razorpay\Api\QrCode::fetchAllPayments + */ + public function testQrCodeCoverage(){ + $qrCode = new QrCodeTest(); + $qrCode->setup(); + $qrCode->testCreateQrCode(); + $qrCode->testFetchQrCode(); + $qrCode->testCloseQrCode(); + $qrCode->testFetchAllQrCode(); + } + + /** + * @covers \Razorpay\Api\Refund::fetch + * @covers \Razorpay\Api\Refund::edit + * @covers \Razorpay\Api\Refund::all + */ + public function testRefundCoverage(){ + $refund = new RefundTest(); + $refund->setup(); + $refund->testFetchRefund(); + $refund->testUpdateRefund(); + $refund->testFetchAllRefund(); + } } \ No newline at end of file diff --git a/tests/PaymentLinkTest.php b/tests/PaymentLinkTest.php index 6b6fb21a..886a3a84 100644 --- a/tests/PaymentLinkTest.php +++ b/tests/PaymentLinkTest.php @@ -24,7 +24,7 @@ public function testCreatePaymentLink() { $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', - 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) , + 'email' => 'gaurav.kumar@example.com', 'contact'=>'9000090000'), 'notify'=>array('sms'=>true, 'email'=>true) , 'reminder_enable'=>true ,'notes'=>array('policy_name'=> 'Jeevan Bima'),'callback_url' => 'https://example-callback-url.com/', 'callback_method'=>'get')); @@ -64,7 +64,13 @@ public function testFetchRefund() */ public function testUpdatePaymentLink() { - $data = $this->api->paymentLink->fetch($this->paymentLinkId)->edit(array("reference_id"=>"TS".time(), "reminder_enable"=>0, "notes"=>["policy_name"=>"Jeevan Saral 2"])); + $payment = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, + 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', + 'email' => 'gaurav.kumar@example.com', 'contact'=>'9000090000'), 'notify'=>array('sms'=>true, 'email'=>true) , + 'reminder_enable'=>true ,'notes'=>array('policy_name'=> 'Jeevan Bima'),'callback_url' => 'https://example-callback-url.com/', + 'callback_method'=>'get')); + + $data = $this->api->paymentLink->fetch($payment->id)->edit(array("reference_id"=>"TS".time(), "reminder_enable"=>0, "notes"=>["policy_name"=>"Jeevan Saral 2"])); $this->assertTrue(is_array($data->toArray())); @@ -91,7 +97,7 @@ public function testCancelPaymentLink() { $paymentLink = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', - 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) , + 'email' => 'gaurav.kumar@example.com', 'contact'=>'9000090000'), 'notify'=>array('sms'=>true, 'email'=>true) , 'reminder_enable'=>true ,'notes'=>array('policy_name'=> 'Jeevan Bima'),'callback_url' => 'https://example-callback-url.com/', 'callback_method'=>'get')); @@ -107,7 +113,7 @@ public function testCancelPaymentLink() */ public function testCreateTransferPayments() { - $data = $this->api->paymentLink->create(array('amount'=>20000, 'currency'=>'INR', 'accept_partial'=>false, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('order'=>array('transfers'=>array('account'=>'acc_CPRsN1LkFccllA', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Bhairav Kumar' ,'linked_account_notes'=>array('branch'))), array('account'=>'acc_CNo3jSI8OkFJJJ', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Saurav Kumar' ,'linked_account_notes'=>array('branch'))))))); + $data = $this->api->paymentLink->create(array('amount'=>20000, 'currency'=>'INR', 'accept_partial'=>false, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'9000090000'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('order'=>array('transfers'=>array('account'=>'acc_CPRsN1LkFccllA', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Bhairav Kumar' ,'linked_account_notes'=>array('branch'))), array('account'=>'acc_CNo3jSI8OkFJJJ', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Saurav Kumar' ,'linked_account_notes'=>array('branch'))))))); $this->assertTrue(is_array($data->toArray())); @@ -119,7 +125,7 @@ public function testCreateTransferPayments() */ public function testOfferPaymentLinks() { - $data = $this->api->paymentLink->create(array('amount'=>20000, 'currency'=>'INR', 'accept_partial'=>false, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('order'=>array('transfers'=>array('account'=>'acc_CPRsN1LkFccllA', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Bhairav Kumar' ,'linked_account_notes'=>array('branch'))), array('account'=>'acc_CNo3jSI8OkFJJJ', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Saurav Kumar' ,'linked_account_notes'=>array('branch'))))))); + $data = $this->api->paymentLink->create(array('amount'=>20000, 'currency'=>'INR', 'accept_partial'=>false, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'9000090000'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('order'=>array('transfers'=>array('account'=>'acc_CPRsN1LkFccllA', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Bhairav Kumar' ,'linked_account_notes'=>array('branch'))), array('account'=>'acc_CNo3jSI8OkFJJJ', 'amount'=>500, 'currency'=>'INR', 'notes'=>array('branch'=>'Acme Corp Bangalore North', 'name'=>'Saurav Kumar' ,'linked_account_notes'=>array('branch'))))))); $this->assertTrue(is_array($data->toArray())); @@ -131,7 +137,7 @@ public function testOfferPaymentLinks() */ public function testManagingRemainder() { - $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>false)); + $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'9000090000'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>false)); $this->assertTrue(is_array($data->toArray())); @@ -143,7 +149,7 @@ public function testManagingRemainder() */ public function testRenameLabelsCheckout() { - $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('partial_payment'=>array('min_amount_label'=>'Minimum Money to be paid', 'partial_amount_label'=>'Pay in parts', 'partial_amount_description'=>'Pay at least ₹100', 'full_amount_label'=>'Pay the entire amount'))))); + $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'9000090000'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('partial_payment'=>array('min_amount_label'=>'Minimum Money to be paid', 'partial_amount_label'=>'Pay in parts', 'partial_amount_description'=>'Pay at least ₹100', 'full_amount_label'=>'Pay the entire amount'))))); $this->assertTrue(is_array($data->toArray())); @@ -155,7 +161,7 @@ public function testRenameLabelsCheckout() */ public function testBusinessName() { - $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('name'=>'Lacme Corp')))); + $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'9000090000'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('name'=>'Lacme Corp')))); $this->assertTrue(is_array($data->toArray())); @@ -167,7 +173,7 @@ public function testBusinessName() */ public function testCheckoutFields() { - $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('method'=>array('netbanking'=>'1', 'card'=>'1', 'upi'=>'0', 'wallet'=>'0'))))); + $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'9000090000'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('checkout'=>array('method'=>array('netbanking'=>'1', 'card'=>'1', 'upi'=>'0', 'wallet'=>'0'))))); $this->assertTrue(is_array($data->toArray())); @@ -179,7 +185,7 @@ public function testCheckoutFields() */ public function testRenameLabelsPayments() { - $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'+919999999999'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('hosted_page'=>array('label'=>array('receipt'=>'Ref No.'.time(), 'description'=>'Course Name', 'amount_payable'=>'Course Fee Payable', 'amount_paid'=>'Course Fee Paid', 'partial_amount_due'=>'Fee Installment Due', 'partial_amount_paid'=>'Fee Installment Paid', 'expire_by'=>'Pay Before', 'expired_on'=>'1632223497','amount_due'=>'Course Fee Due'), 'show_preferences'=>array('issued_to'=>false))))); + $data = $this->api->paymentLink->create(array('amount'=>500, 'currency'=>'INR', 'accept_partial'=>true, 'first_min_partial_amount'=>100, 'description' => 'For XYZ purpose', 'customer' => array('name'=>'Gaurav Kumar', 'email' => 'gaurav.kumar@example.com', 'contact'=>'9000090000'), 'notify'=>array('sms'=>true, 'email'=>true) ,'reminder_enable'=>true , 'options'=>array('hosted_page'=>array('label'=>array('receipt'=>'Ref No.'.time(), 'description'=>'Course Name', 'amount_payable'=>'Course Fee Payable', 'amount_paid'=>'Course Fee Paid', 'partial_amount_due'=>'Fee Installment Due', 'partial_amount_paid'=>'Fee Installment Paid', 'expire_by'=>'Pay Before', 'expired_on'=>'1632223497','amount_due'=>'Course Fee Due'), 'show_preferences'=>array('issued_to'=>false))))); $this->assertTrue(is_array($data->toArray())); diff --git a/tests/QrCodeTest.php b/tests/QrCodeTest.php index e4f08233..7bc21b1a 100644 --- a/tests/QrCodeTest.php +++ b/tests/QrCodeTest.php @@ -83,7 +83,7 @@ public function testFetchQrCodePaymentById() */ public function testCloseQrCode() { - $qrCodeId = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $customerId, "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); + $qrCodeId = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $this->customerId, "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); $data = $this->api->qrCode->fetch($qrCodeId->id)->close(); diff --git a/tests/RefundTest.php b/tests/RefundTest.php index 3d5af4f9..2f322bb0 100644 --- a/tests/RefundTest.php +++ b/tests/RefundTest.php @@ -8,12 +8,12 @@ class RefundTest extends TestCase { /** * Specify unique payment id & refund id - * for example plan_IEeswu4zFBRGwi & rfnd_IEjzeVghAS4vd1 + * for example pay_LatkcPaGiDxgRG & rfnd_IEjzeVghAS4vd1 */ - private $paymentId = "plan_IEeswu4zFBRGwi"; + private $paymentId = "pay_LatkcPaGiDxgRG"; - private $refundId = "rfnd_IEjzeVghAS4vd1"; + private $refundId = "rfnd_Lcsb6JNwQVAtpi"; public function setUp(): void { From e1f59f13a56da18e4e6d493a62aa9b0cfe715eda Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Wed, 12 Apr 2023 19:55:33 +0530 Subject: [PATCH 34/46] Update CoverageTest.php --- tests/CoverageTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index 78364711..545d7810 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -154,7 +154,7 @@ public function testPaymentlinkCoverage(){ public function testQrCodeCoverage(){ $qrCode = new QrCodeTest(); $qrCode->setup(); - $qrCode->testCreateQrCode(); + //$qrCode->testCreateQrCode(); $qrCode->testFetchQrCode(); $qrCode->testCloseQrCode(); $qrCode->testFetchAllQrCode(); @@ -169,7 +169,7 @@ public function testRefundCoverage(){ $refund = new RefundTest(); $refund->setup(); $refund->testFetchRefund(); - $refund->testUpdateRefund(); + //$refund->testUpdateRefund(); $refund->testFetchAllRefund(); } -} \ No newline at end of file +} From bfd5e645babbb3f51d892d40d6223f25cd17d364 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Wed, 12 Apr 2023 20:00:35 +0530 Subject: [PATCH 35/46] Update CoverageTest.php --- tests/CoverageTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index 545d7810..1ebab540 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -156,7 +156,7 @@ public function testQrCodeCoverage(){ $qrCode->setup(); //$qrCode->testCreateQrCode(); $qrCode->testFetchQrCode(); - $qrCode->testCloseQrCode(); + //$qrCode->testCloseQrCode(); $qrCode->testFetchAllQrCode(); } From 67e010697c38c8299bc6f9ebe1809c2677fb6173 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Thu, 13 Apr 2023 13:32:59 +0530 Subject: [PATCH 36/46] add test cases --- tests/CoverageTest.php | 96 +++++++++++++++++++++++++++++++--------- tests/SettlementTest.php | 8 ++-- 2 files changed, 78 insertions(+), 26 deletions(-) diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index 1ebab540..f8c89e0b 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -6,6 +6,65 @@ class CoverageTest extends TestCase { + /** + * @covers \Razorpay\Api\QrCode::create + * @covers \Razorpay\Api\QrCode::fetch + * @covers \Razorpay\Api\QrCode::close + * @covers \Razorpay\Api\QrCode::all + * @covers \Razorpay\Api\QrCode::fetchAllPayments + */ + public function testQrCodeCoverage(){ + $qrCode = new QrCodeTest(); + $qrCode->setup(); + $qrCode->testCreateQrCode(); + $qrCode->testFetchQrCode(); + $qrCode->testCloseQrCode(); + $qrCode->testFetchAllQrCode(); + } + + /** + * @covers \Razorpay\Api\Refund::fetch + * @covers \Razorpay\Api\Refund::edit + * @covers \Razorpay\Api\Refund::all + */ + public function testRefundCoverage(){ + $refund = new RefundTest(); + $refund->setup(); + $refund->testFetchRefund(); + $refund->testUpdateRefund(); + $refund->testFetchAllRefund(); + } + + /** + * @covers \Razorpay\Api\Subscription::create + * @covers \Razorpay\Api\Subscription::fetch + * @covers \Razorpay\Api\Addon::fetchAll + * @covers \Razorpay\Api\Subscription::all + */ + public function testSubscriptionCoverage(){ + $subscription = new SubscriptionTest(); + $subscription->setup(); + $subscription->testCreateSubscription(); + $subscription->testSubscriptionFetchId(); + $subscription->testFetchAddons(); + $subscription->testFetchAllSubscriptions(); + } + + /** + * @covers \Razorpay\Api\VirtualAccount::create + * @covers \Razorpay\Api\VirtualAccount::all + * @covers \Razorpay\Api\VirtualAccount::payments + * @covers \Razorpay\Api\VirtualAccount::close + */ + public function testVirtualAccountCoverage(){ + $virtualAccount = new VirtualAccountTest(); + $virtualAccount->setup(); + $virtualAccount->testCreateVirtualAccount(); + $virtualAccount->testFetchAllVirtualAccounts(); + $virtualAccount->testFetchPayment(); + $virtualAccount->testCloseVirtualAccount(); + } + /** * @covers \Razorpay\Api\Addon::fetch * @covers \Razorpay\Api\Addon::fetchAll @@ -125,7 +184,7 @@ public function testPaymentCoverage(){ $order->testfetchPaymentDowntimeById(); } - /** + /** * @covers \Razorpay\Api\PaymentLink::create * @covers \Razorpay\Api\PaymentLink::fetch * @covers \Razorpay\Api\PaymentLink::all @@ -145,31 +204,24 @@ public function testPaymentlinkCoverage(){ } /** - * @covers \Razorpay\Api\QrCode::create - * @covers \Razorpay\Api\QrCode::fetch - * @covers \Razorpay\Api\QrCode::close - * @covers \Razorpay\Api\QrCode::all - * @covers \Razorpay\Api\QrCode::fetchAllPayments + * @covers \Razorpay\Api\Settlement::all + * @covers \Razorpay\Api\Settlement::settlementRecon */ - public function testQrCodeCoverage(){ - $qrCode = new QrCodeTest(); - $qrCode->setup(); - //$qrCode->testCreateQrCode(); - $qrCode->testFetchQrCode(); - //$qrCode->testCloseQrCode(); - $qrCode->testFetchAllQrCode(); + public function testSettlementCoverage(){ + $paymentlink = new SettlementTest(); + $paymentlink->setup(); + $paymentlink->testAllSettlements(); + $paymentlink->testSettlementRecon(); } /** - * @covers \Razorpay\Api\Refund::fetch - * @covers \Razorpay\Api\Refund::edit - * @covers \Razorpay\Api\Refund::all + * @covers \Razorpay\Api\Order::transfers + * @covers \Razorpay\Api\Transfer::all */ - public function testRefundCoverage(){ - $refund = new RefundTest(); - $refund->setup(); - $refund->testFetchRefund(); - //$refund->testUpdateRefund(); - $refund->testFetchAllRefund(); + public function testTransferCoverage(){ + $transfer = new TransferTest(); + $transfer->setup(); + $transfer->testFetchTransferOrder(); + $transfer->testFetchSettlement();; } } diff --git a/tests/SettlementTest.php b/tests/SettlementTest.php index f353cca0..963e2961 100644 --- a/tests/SettlementTest.php +++ b/tests/SettlementTest.php @@ -80,9 +80,9 @@ public function testSettlementRecon() /** * Fetch all on-demand settlements */ - public function TestFetchAllOndemandSettlement() + public function testFetchAllOndemandSettlement() { - $data = $api->settlement->fetchAllOndemandSettlement(); + $data = $this->api->settlement->fetchAllOndemandSettlement(); $this->assertTrue(is_array($data->toArray())); @@ -92,9 +92,9 @@ public function TestFetchAllOndemandSettlement() /** * Fetch on-demand settlement by ID */ - public function TestFetchAllOndemandSettlementById() + public function testFetchAllOndemandSettlementById() { - $data = $api->settlement->fetch($this->settlementId)->TestFetchAllOndemandSettlementById(); + $data = $this->api->settlement->fetch($this->settlementId)->TestFetchAllOndemandSettlementById(); $this->assertTrue(is_array($data->toArray())); From 06f58cb6fd2200eac187b207b4c91c66e6490003 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 14 Apr 2023 12:43:45 +0530 Subject: [PATCH 37/46] optimize test cases --- phpunit.xml.dist | 11 ++++++++++- tests/CoverageTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 697062a5..26878044 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,7 +14,16 @@ ./src - + + ./src/Errors + ./src/Api.php + ./src/ArrayableInterface.php + ./src/Collection.php + ./src/Entity.php + ./src/Request.php + ./src/Resource.php + ./src/Webhook.php + diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index f8c89e0b..d6769b01 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -6,6 +6,19 @@ class CoverageTest extends TestCase { + /** + * @covers \Razorpay\Api\Plan::create + * @covers \Razorpay\Api\Plan::fetch + * @covers \Razorpay\Api\Plan::all + */ + public function testPlanCoverage(){ + $subscription = new PlanTest(); + $subscription->setup(); + $subscription->testCreatePlan(); + $subscription->testFetchAllPlans(); + $subscription->testFetchPlan(); + } + /** * @covers \Razorpay\Api\QrCode::create * @covers \Razorpay\Api\QrCode::fetch @@ -89,6 +102,7 @@ public function testCustomerCoverage(){ $customer->testEditCustomer(); $customer->testFetchAll(); $customer->testFetchCustomer(); + usleep(500000); } /** @@ -224,4 +238,15 @@ public function testTransferCoverage(){ $transfer->testFetchTransferOrder(); $transfer->testFetchSettlement();; } + + /** + * @covers \Razorpay\Api\Token::all + * @covers \Razorpay\Api\Token::fetch + */ + public function testTokenCoverage(){ + $transfer = new TokenTest(); + $transfer->setup(); + $transfer->testFetchTokenByCustomerId(); + $transfer->testFetchTokenByPaymentId();; + } } From e4d7fd2adc69e8e5d7657ed2ce4ea68aef9dbc15 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 14 Apr 2023 14:28:31 +0530 Subject: [PATCH 38/46] add more testcases --- tests/CoverageTest.php | 14 +++++++++++++- tests/TransferTest.php | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index d6769b01..0ffa1198 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -33,12 +33,15 @@ public function testQrCodeCoverage(){ $qrCode->testFetchQrCode(); $qrCode->testCloseQrCode(); $qrCode->testFetchAllQrCode(); + $qrCode->testFetchQrCodePaymentById(); } /** * @covers \Razorpay\Api\Refund::fetch * @covers \Razorpay\Api\Refund::edit * @covers \Razorpay\Api\Refund::all + * @covers \Razorpay\Api\Payment::fetchMultipleRefund + * @covers \Razorpay\Api\Payment::fetchRefund */ public function testRefundCoverage(){ $refund = new RefundTest(); @@ -46,6 +49,8 @@ public function testRefundCoverage(){ $refund->testFetchRefund(); $refund->testUpdateRefund(); $refund->testFetchAllRefund(); + $refund->testFetchMultipalRefund(); + $refund->testFetchRefund(); } /** @@ -67,6 +72,7 @@ public function testSubscriptionCoverage(){ * @covers \Razorpay\Api\VirtualAccount::create * @covers \Razorpay\Api\VirtualAccount::all * @covers \Razorpay\Api\VirtualAccount::payments + * @uses \Razorpay\Api\VirtualAccount::fetch * @covers \Razorpay\Api\VirtualAccount::close */ public function testVirtualAccountCoverage(){ @@ -231,12 +237,18 @@ public function testSettlementCoverage(){ /** * @covers \Razorpay\Api\Order::transfers * @covers \Razorpay\Api\Transfer::all + * @covers \Razorpay\Api\Payment::transfers + * @covers \Razorpay\Api\Transfer::fetch + * @covers \Razorpay\Api\Transfer::all */ public function testTransferCoverage(){ $transfer = new TransferTest(); $transfer->setup(); $transfer->testFetchTransferOrder(); - $transfer->testFetchSettlement();; + $transfer->testFetchSettlement(); + $transfer->testFetchTransferPayment(); + $transfer->testFetchTransfer(); + $transfer->testFetchSettlement(); } /** diff --git a/tests/TransferTest.php b/tests/TransferTest.php index 9217b6cb..2d2efb84 100644 --- a/tests/TransferTest.php +++ b/tests/TransferTest.php @@ -12,11 +12,11 @@ class TransferTest extends TestCase * pay_I7watngocuEY4P */ - private $transferId = "trf_IEn4KYFgfD7q3F"; + private $transferId = "trf_JtBI1uAaDdKkpJ"; private $accountId = "acc_HjVXbtpSCIxENR"; - private $paymentId = "pay_I7watngocuEY4P"; + private $paymentId = "pay_LdarHRbodWJeXO"; public function setUp(): void { From e057d225f9f91937cb9a683dcfaa93ee6cee6b07 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 14 Apr 2023 14:34:29 +0530 Subject: [PATCH 39/46] update settings --- phpunit.xml.dist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 26878044..38b05e02 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -22,7 +22,9 @@ ./src/Entity.php ./src/Request.php ./src/Resource.php + ./src/PaymentPage.php ./src/Webhook.php + ./src/Utility.php From b78bc829e9a29086a326fa076bab3737561177f9 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 14 Apr 2023 15:58:40 +0530 Subject: [PATCH 40/46] handle library --- tests/TestCase.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index fb6b7f84..8f4426c3 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -8,18 +8,20 @@ use PHPUnit\Framework\TestCase as PhpUnitTest; use Dotenv\Dotenv; -$dotenv = Dotenv::createImmutable(__DIR__); -$dotenv->load(); - +if (class_exists('Dotenv')) +{ + $dotenv = Dotenv::createImmutable(__DIR__); + $dotenv->load(); +} class TestCase extends PhpUnitTest { public function setUp(): void { - $apiKey = getenv("RAZORPAY_API_KEY"); - $apiSecret = getenv("RAZORPAY_API_SECRET"); + $apiKey = getenv("RAZORPAY_API_KEY") ? getenv("RAZORPAY_API_KEY") : ""; + $apiSecret = getenv("RAZORPAY_API_SECRET") ? getenv("RAZORPAY_API_SECRET") : ""; $this->api = new Api( $apiKey, $apiSecret); } -} +} \ No newline at end of file From 6442489ae6d9139be0e855f7900882f30777e2df Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Mon, 17 Apr 2023 15:15:04 +0530 Subject: [PATCH 41/46] add instance class --- phpunit.xml.dist | 1 - tests/CoverageTest.php | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 38b05e02..79874059 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,7 +16,6 @@ ./src/Errors - ./src/Api.php ./src/ArrayableInterface.php ./src/Collection.php ./src/Entity.php diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index 0ffa1198..fd4faf08 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -6,6 +6,24 @@ class CoverageTest extends TestCase { + /** + * @covers \Razorpay\Api\Api::getAppsDetails + * @uses \Razorpay\Api\Api::setAppDetails + * @covers \Razorpay\Api\Api::getBaseUrl + * @uses \Razorpay\Api\Api::setBaseUrl + * @cover \Razorpay\Api\Api::getKey + * @cover \Razorpay\Api\Api::getSecret + * @cover \Razorpay\Api\Api::getFullUrl + */ + public function testApiInstance(){ + $instance = new ApiTest(); + $instance->setup(); + $instance->testGetAppDetails(); + $instance->testSetBaseUrl(); + $instance->testGetkey(); + $instance->testGetSecret(); + $instance->testFullUrl(); + } /** * @covers \Razorpay\Api\Plan::create * @covers \Razorpay\Api\Plan::fetch From 290975a0899a39c737fa08ccf212e89bdfff052a Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Mon, 17 Apr 2023 15:30:30 +0530 Subject: [PATCH 42/46] parameter change --- tests/ApiTest.php | 66 ++++++++++++++++++++++++++++++++++++ tests/QrCodeTest.php | 2 +- tests/VirtualAccountTest.php | 2 +- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 tests/ApiTest.php diff --git a/tests/ApiTest.php b/tests/ApiTest.php new file mode 100644 index 00000000..3f3b3577 --- /dev/null +++ b/tests/ApiTest.php @@ -0,0 +1,66 @@ +api->setAppDetails($this->title); + + $data = $this->api->getAppsDetails(); + + $this->assertTrue(is_array($data)); + + $this->assertTrue($this->title==$data[0]['title']); + } + + /** + * Get app details + */ + public function testSetBaseUrl() + { + $this->api->setBaseUrl($this->url); + + $data = $this->api->getBaseUrl(); + + $this->assertTrue($this->url==$data); + + } + + public function testGetkey() + { + $data = $this->api->getKey(); + print_r($data); + $this->assertTrue(strlen($data) > 0); + } + + public function testGetSecret() + { + $data = $this->api->getSecret(); + $this->assertTrue(strlen($data) > 0); + } + + public function testFullUrl() + { + $pattern = '/^(https?:\/\/)?([a-z0-9-]+\.)+[a-z]{2,}(\/.*)?$/i'; + $url = $this->api->getFullUrl($this->api->getBaseUrl()."orders"); + $this->assertTrue(preg_match($pattern, $url, $matches)==true); + } + +} \ No newline at end of file diff --git a/tests/QrCodeTest.php b/tests/QrCodeTest.php index 7bc21b1a..1496f92a 100644 --- a/tests/QrCodeTest.php +++ b/tests/QrCodeTest.php @@ -25,7 +25,7 @@ public function setUp(): void */ public function testCreateQrCode() { - $data = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $this->customerId, "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); + $data = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $this->customerId, "description" => "For Store 1","close_by" => strtotime('+2 minutes', time()),"notes" => array("purpose" => "Test UPI QR code notes"))); $this->assertTrue(is_array($data->toArray())); diff --git a/tests/VirtualAccountTest.php b/tests/VirtualAccountTest.php index bf891e46..fde99a18 100644 --- a/tests/VirtualAccountTest.php +++ b/tests/VirtualAccountTest.php @@ -28,7 +28,7 @@ public function setUp(): void */ public function testCreateVirtualAccount() { - $data = $this->api->virtualAccount->create(array('receivers' => array('types' => array('bank_account')),'description' => 'Virtual Account created for Raftar Soft','customer_id' => $this->customerId ,'close_by' => 1681615838,'notes' => array('project_name' => 'Banking Software'))); + $data = $this->api->virtualAccount->create(array('receivers' => array('types' => array('bank_account')),'description' => 'Virtual Account created for Raftar Soft','customer_id' => $this->customerId ,'close_by' => strtotime('+15 minutes', time()), 'notes' => array('project_name' => 'Banking Software'))); $this->assertTrue(is_array($data->toArray())); From 941437983547e028fd02f73a0979bbade0363853 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Mon, 17 Apr 2023 15:49:11 +0530 Subject: [PATCH 43/46] add changes --- phpunit.xml.dist | 11 ----------- tests/CoverageTest.php | 1 + tests/QrCodeTest.php | 4 ++-- tests/VirtualAccountTest.php | 2 +- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 79874059..9bb045c3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,17 +14,6 @@ ./src - - ./src/Errors - ./src/ArrayableInterface.php - ./src/Collection.php - ./src/Entity.php - ./src/Request.php - ./src/Resource.php - ./src/PaymentPage.php - ./src/Webhook.php - ./src/Utility.php - diff --git a/tests/CoverageTest.php b/tests/CoverageTest.php index fd4faf08..cc92a6d1 100644 --- a/tests/CoverageTest.php +++ b/tests/CoverageTest.php @@ -41,6 +41,7 @@ public function testPlanCoverage(){ * @covers \Razorpay\Api\QrCode::create * @covers \Razorpay\Api\QrCode::fetch * @covers \Razorpay\Api\QrCode::close + * @uses \Razorpay\Api\ArrayableInterface * @covers \Razorpay\Api\QrCode::all * @covers \Razorpay\Api\QrCode::fetchAllPayments */ diff --git a/tests/QrCodeTest.php b/tests/QrCodeTest.php index 1496f92a..e63a07d5 100644 --- a/tests/QrCodeTest.php +++ b/tests/QrCodeTest.php @@ -25,7 +25,7 @@ public function setUp(): void */ public function testCreateQrCode() { - $data = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $this->customerId, "description" => "For Store 1","close_by" => strtotime('+2 minutes', time()),"notes" => array("purpose" => "Test UPI QR code notes"))); + $data = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $this->customerId, "description" => "For Store 1","close_by" => strtotime('+3 minutes', time()),"notes" => array("purpose" => "Test UPI QR code notes"))); $this->assertTrue(is_array($data->toArray())); @@ -83,7 +83,7 @@ public function testFetchQrCodePaymentById() */ public function testCloseQrCode() { - $qrCodeId = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $this->customerId, "description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); + $qrCodeId = $this->api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => $this->customerId, "description" => "For Store 1","close_by" => strtotime('+3 minutes', time()), "notes" => array("purpose" => "Test UPI QR code notes"))); $data = $this->api->qrCode->fetch($qrCodeId->id)->close(); diff --git a/tests/VirtualAccountTest.php b/tests/VirtualAccountTest.php index fde99a18..e2cdbf1b 100644 --- a/tests/VirtualAccountTest.php +++ b/tests/VirtualAccountTest.php @@ -28,7 +28,7 @@ public function setUp(): void */ public function testCreateVirtualAccount() { - $data = $this->api->virtualAccount->create(array('receivers' => array('types' => array('bank_account')),'description' => 'Virtual Account created for Raftar Soft','customer_id' => $this->customerId ,'close_by' => strtotime('+15 minutes', time()), 'notes' => array('project_name' => 'Banking Software'))); + $data = $this->api->virtualAccount->create(array('receivers' => array('types' => array('bank_account')),'description' => 'Virtual Account created for Raftar Soft','customer_id' => $this->customerId ,'close_by' => strtotime('+16 minutes', time()), 'notes' => array('project_name' => 'Banking Software'))); $this->assertTrue(is_array($data->toArray())); From 0cccdbc8fbcc537bacf47bb4c8e3606f528cd13e Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Mon, 17 Apr 2023 15:54:51 +0530 Subject: [PATCH 44/46] remove print --- tests/ApiTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ApiTest.php b/tests/ApiTest.php index 3f3b3577..27b50914 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -46,7 +46,7 @@ public function testSetBaseUrl() public function testGetkey() { $data = $this->api->getKey(); - print_r($data); + $this->assertTrue(strlen($data) > 0); } From 593595c05a903f9c4dac3546b8736f5b455cdd9c Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Mon, 17 Apr 2023 16:23:42 +0530 Subject: [PATCH 45/46] revert changes --- phpunit.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9bb045c3..653f23ce 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,6 +14,7 @@ ./src + From 90838fbd93aaa008f96374e165db5f7064bca104 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Mon, 17 Apr 2023 16:24:07 +0530 Subject: [PATCH 46/46] revert changes --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 653f23ce..697062a5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,7 +14,7 @@ ./src - +