Skip to content
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 46 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e071612
feat: Test coverage
ankitdas13 Apr 10, 2023
d182004
add coverage script
ankitdas13 Apr 10, 2023
bf3a8d8
Update ci.yml
ankitdas13 Apr 10, 2023
7fb2706
Update ci.yml
ankitdas13 Apr 10, 2023
1ef9752
Update TestCase.php
ankitdas13 Apr 10, 2023
97c659b
Update TestCase.php
ankitdas13 Apr 11, 2023
ce3811c
Update ci.yml
ankitdas13 Apr 11, 2023
b7c0811
Update ci.yml
ankitdas13 Apr 11, 2023
4d28312
Update TestCase.php
ankitdas13 Apr 11, 2023
c334d60
Update ci.yml
ankitdas13 Apr 11, 2023
71bac34
Update ci.yml
ankitdas13 Apr 11, 2023
62cc76d
Update TestCase.php
ankitdas13 Apr 11, 2023
82432d4
Update ci.yml
ankitdas13 Apr 11, 2023
f62db10
Update ci.yml
ankitdas13 Apr 11, 2023
1046a50
Update ci.yml
ankitdas13 Apr 11, 2023
93cff68
Update ci.yml
ankitdas13 Apr 11, 2023
0cf7434
Update ci.yml
ankitdas13 Apr 11, 2023
83569f2
Update ci.yml
ankitdas13 Apr 11, 2023
6880b74
Update ci.yml
ankitdas13 Apr 11, 2023
f7b6699
Update ci.yml
ankitdas13 Apr 11, 2023
4077921
Update ci.yml
ankitdas13 Apr 11, 2023
064b89b
Create .env
ankitdas13 Apr 11, 2023
f14331e
Update ci.yml
ankitdas13 Apr 11, 2023
24fec60
Update ci.yml
ankitdas13 Apr 11, 2023
794f9d5
Update TestCase.php
ankitdas13 Apr 11, 2023
55e8cfb
Delete .env
ankitdas13 Apr 11, 2023
04846b5
Update TestCase.php
ankitdas13 Apr 11, 2023
4f2a2d7
Update TestCase.php
ankitdas13 Apr 11, 2023
770c432
Update ci.yml
ankitdas13 Apr 12, 2023
483ec08
update cases
ankitdas13 Apr 12, 2023
26b84b5
update cases
ankitdas13 Apr 12, 2023
0013ff9
update cases
ankitdas13 Apr 12, 2023
2f8db19
update cases and params
ankitdas13 Apr 12, 2023
e1f59f1
Update CoverageTest.php
ankitdas13 Apr 12, 2023
bfd5e64
Update CoverageTest.php
ankitdas13 Apr 12, 2023
67e0106
add test cases
ankitdas13 Apr 13, 2023
06f58cb
optimize test cases
ankitdas13 Apr 14, 2023
e4d7fd2
add more testcases
ankitdas13 Apr 14, 2023
e057d22
update settings
ankitdas13 Apr 14, 2023
b78bc82
handle library
ankitdas13 Apr 14, 2023
6442489
add instance class
ankitdas13 Apr 17, 2023
290975a
parameter change
ankitdas13 Apr 17, 2023
9414379
add changes
ankitdas13 Apr 17, 2023
0cccdbc
remove print
ankitdas13 Apr 17, 2023
593595c
revert changes
ankitdas13 Apr 17, 2023
90838fb
revert changes
ankitdas13 Apr 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
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
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<include>
<directory>./src</directory>
</include>
<exclude/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this

</coverage>
<php>
<!-- copy this file to phpunit.xml and replace with your API key to run tests -->
Expand Down
66 changes: 66 additions & 0 deletions tests/ApiTest.php
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);
}

}
30 changes: 30 additions & 0 deletions tests/CardTest.php
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()));
}

}
Loading