-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d348d97
commit d9901af
Showing
11 changed files
with
452 additions
and
24 deletions.
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
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.