-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Test coverage #346
Merged
Merged
feat: Test coverage #346
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
e071612
feat: Test coverage
ankitdas13 d182004
add coverage script
ankitdas13 bf3a8d8
Update ci.yml
ankitdas13 7fb2706
Update ci.yml
ankitdas13 1ef9752
Update TestCase.php
ankitdas13 97c659b
Update TestCase.php
ankitdas13 ce3811c
Update ci.yml
ankitdas13 b7c0811
Update ci.yml
ankitdas13 4d28312
Update TestCase.php
ankitdas13 c334d60
Update ci.yml
ankitdas13 71bac34
Update ci.yml
ankitdas13 62cc76d
Update TestCase.php
ankitdas13 82432d4
Update ci.yml
ankitdas13 f62db10
Update ci.yml
ankitdas13 1046a50
Update ci.yml
ankitdas13 93cff68
Update ci.yml
ankitdas13 0cf7434
Update ci.yml
ankitdas13 83569f2
Update ci.yml
ankitdas13 6880b74
Update ci.yml
ankitdas13 f7b6699
Update ci.yml
ankitdas13 4077921
Update ci.yml
ankitdas13 064b89b
Create .env
ankitdas13 f14331e
Update ci.yml
ankitdas13 24fec60
Update ci.yml
ankitdas13 794f9d5
Update TestCase.php
ankitdas13 55e8cfb
Delete .env
ankitdas13 04846b5
Update TestCase.php
ankitdas13 4f2a2d7
Update TestCase.php
ankitdas13 770c432
Update ci.yml
ankitdas13 483ec08
update cases
ankitdas13 26b84b5
update cases
ankitdas13 0013ff9
update cases
ankitdas13 2f8db19
update cases and params
ankitdas13 e1f59f1
Update CoverageTest.php
ankitdas13 bfd5e64
Update CoverageTest.php
ankitdas13 67e0106
add test cases
ankitdas13 06f58cb
optimize test cases
ankitdas13 e4d7fd2
add more testcases
ankitdas13 e057d22
update settings
ankitdas13 b78bc82
handle library
ankitdas13 6442489
add instance class
ankitdas13 290975a
parameter change
ankitdas13 9414379
add changes
ankitdas13 0cccdbc
remove print
ankitdas13 593595c
revert changes
ankitdas13 90838fb
revert changes
ankitdas13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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: '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 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace Razorpay\Tests; | ||
|
||
use Razorpay\Api\Request; | ||
|
||
class ApiTest extends TestCase | ||
{ | ||
|
||
private $title = "codecov_test"; | ||
|
||
private $url = 'https://api.razorpay.com/v1/'; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* Get app details | ||
*/ | ||
public function testGetAppDetails() | ||
{ | ||
$this->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(); | ||
|
||
$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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Razorpay\Tests; | ||
|
||
use Razorpay\Api\Request; | ||
|
||
class CardTest extends TestCase | ||
{ | ||
/** | ||
* Specify unique card id | ||
*/ | ||
|
||
private $cardId = "card_LcQgzpfvWP0UKF"; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* Fetch Card details | ||
*/ | ||
public function testFetchCard() | ||
{ | ||
$data = $this->api->card->fetch($this->cardId); | ||
|
||
$this->assertTrue(in_array($this->cardId, $data->toArray())); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert this