Skip to content

Commit f2be466

Browse files
Added test cases
1 parent bad9e89 commit f2be466

File tree

11 files changed

+369
-0
lines changed

11 files changed

+369
-0
lines changed

tests/FacadeGatewayTestCase.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/laravel-omnipay
4+
*
5+
* @copyright (c) PHP Viet
6+
* @license [MIT](https://opensource.org/licenses/MIT)
7+
*/
8+
9+
namespace PHPViet\Laravel\Omnipay\Tests;
10+
11+
/**
12+
* @author Vuong Minh <vuongxuongminh@gmail.com>
13+
* @since 1.0.0
14+
*/
15+
abstract class FacadeGatewayTestCase extends TestCase
16+
{
17+
abstract protected function getGatewayAlias(): string;
18+
19+
abstract protected function getGatewayName(): string;
20+
21+
/**
22+
* @var \Omnipay\Common\AbstractGateway
23+
*/
24+
protected $gateway;
25+
26+
protected function setUp(): void
27+
{
28+
parent::setUp();
29+
$this->gateway = $this->getGatewayAlias();
30+
}
31+
32+
public function testCanAccessGateway()
33+
{
34+
$this->assertSame($this->gateway::getName(), $this->getGatewayName());
35+
$this->assertSame($this->gateway::getTestMode(), true);
36+
}
37+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/laravel-omnipay
4+
*
5+
* @copyright (c) PHP Viet
6+
* @license [MIT](https://opensource.org/licenses/MIT)
7+
*/
8+
9+
namespace PHPViet\Laravel\Omnipay\Tests\Facades\MoMo;
10+
11+
use PHPViet\Laravel\Omnipay\Tests\FacadeGatewayTestCase;
12+
13+
/**
14+
* @author Vuong Minh <vuongxuongminh@gmail.com>
15+
* @since 1.0.0
16+
*/
17+
class AllInOneGatewayTest extends FacadeGatewayTestCase
18+
{
19+
protected function getGatewayName(): string
20+
{
21+
return 'MoMo AIO';
22+
}
23+
24+
protected function getGatewayAlias(): string
25+
{
26+
return '\MoMoAIO';
27+
}
28+
}
29+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/laravel-omnipay
4+
*
5+
* @copyright (c) PHP Viet
6+
* @license [MIT](https://opensource.org/licenses/MIT)
7+
*/
8+
9+
namespace PHPViet\Laravel\Omnipay\Tests\Facades\MoMo;
10+
11+
use PHPViet\Laravel\Omnipay\Tests\FacadeGatewayTestCase;
12+
13+
/**
14+
* @author Vuong Minh <vuongxuongminh@gmail.com>
15+
* @since 1.0.0
16+
*/
17+
class AppInAppGatewayTest extends FacadeGatewayTestCase
18+
{
19+
protected function getGatewayName(): string
20+
{
21+
return 'MoMo AIA';
22+
}
23+
24+
protected function getGatewayAlias(): string
25+
{
26+
return '\MoMoAIA';
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/laravel-omnipay
4+
*
5+
* @copyright (c) PHP Viet
6+
* @license [MIT](https://opensource.org/licenses/MIT)
7+
*/
8+
9+
namespace PHPViet\Laravel\Omnipay\Tests\Facades\MoMo;
10+
11+
use PHPViet\Laravel\Omnipay\Tests\FacadeGatewayTestCase;
12+
13+
/**
14+
* @author Vuong Minh <vuongxuongminh@gmail.com>
15+
* @since 1.0.0
16+
*/
17+
class POSGatewayTest extends FacadeGatewayTestCase
18+
{
19+
protected function getGatewayName(): string
20+
{
21+
return 'MoMo POS';
22+
}
23+
24+
protected function getGatewayAlias(): string
25+
{
26+
return '\MoMoPOS';
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/laravel-omnipay
4+
*
5+
* @copyright (c) PHP Viet
6+
* @license [MIT](https://opensource.org/licenses/MIT)
7+
*/
8+
9+
namespace PHPViet\Laravel\Omnipay\Tests\Facades\MoMo;
10+
11+
use PHPViet\Laravel\Omnipay\Tests\FacadeGatewayTestCase;
12+
13+
/**
14+
* @author Vuong Minh <vuongxuongminh@gmail.com>
15+
* @since 1.0.0
16+
*/
17+
class QRCodeGatewayTest extends FacadeGatewayTestCase
18+
{
19+
protected function getGatewayName(): string
20+
{
21+
return 'MoMo QRCode';
22+
}
23+
24+
protected function getGatewayAlias(): string
25+
{
26+
return '\MoMoQRCode';
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/laravel-omnipay
4+
*
5+
* @copyright (c) PHP Viet
6+
* @license [MIT](https://opensource.org/licenses/MIT)
7+
*/
8+
9+
namespace PHPViet\Laravel\Omnipay\Tests\Facades\OnePay;
10+
11+
use PHPViet\Laravel\Omnipay\Tests\FacadeGatewayTestCase;
12+
13+
/**
14+
* @author Vuong Minh <vuongxuongminh@gmail.com>
15+
* @since 1.0.0
16+
*/
17+
class DomesticGatewayTest extends FacadeGatewayTestCase
18+
{
19+
protected function getGatewayName(): string
20+
{
21+
return 'OnePay Domestic';
22+
}
23+
24+
protected function getGatewayAlias(): string
25+
{
26+
return '\OnePayDomestic';
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/laravel-omnipay
4+
*
5+
* @copyright (c) PHP Viet
6+
* @license [MIT](https://opensource.org/licenses/MIT)
7+
*/
8+
9+
namespace PHPViet\Laravel\Omnipay\Tests\Facades\OnePay;
10+
11+
use PHPViet\Laravel\Omnipay\Tests\FacadeGatewayTestCase;
12+
13+
/**
14+
* @author Vuong Minh <vuongxuongminh@gmail.com>
15+
* @since 1.0.0
16+
*/
17+
class InternationalGatewayTest extends FacadeGatewayTestCase
18+
{
19+
protected function getGatewayName(): string
20+
{
21+
return 'OnePay International';
22+
}
23+
24+
protected function getGatewayAlias(): string
25+
{
26+
return '\OnePayInternational';
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/laravel-omnipay
4+
*
5+
* @copyright (c) PHP Viet
6+
* @license [MIT](https://opensource.org/licenses/MIT)
7+
*/
8+
9+
namespace PHPViet\Laravel\Omnipay\Tests\Facades\VNPay;
10+
11+
use PHPViet\Laravel\Omnipay\Tests\FacadeGatewayTestCase;
12+
13+
/**
14+
* @author Vuong Minh <vuongxuongminh@gmail.com>
15+
* @since 1.0.0
16+
*/
17+
class GatewayTest extends FacadeGatewayTestCase
18+
{
19+
protected function getGatewayName(): string
20+
{
21+
return 'VNPay';
22+
}
23+
24+
protected function getGatewayAlias(): string
25+
{
26+
return '\VNPay';
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/laravel-omnipay
4+
*
5+
* @copyright (c) PHP Viet
6+
* @license [MIT](https://opensource.org/licenses/MIT)
7+
*/
8+
9+
namespace PHPViet\Laravel\Omnipay\Tests\Facades\VTCPay;
10+
11+
use PHPViet\Laravel\Omnipay\Tests\FacadeGatewayTestCase;
12+
13+
/**
14+
* @author Vuong Minh <vuongxuongminh@gmail.com>
15+
* @since 1.0.0
16+
*/
17+
class GatewayTest extends FacadeGatewayTestCase
18+
{
19+
protected function getGatewayName(): string
20+
{
21+
return 'VTCPay';
22+
}
23+
24+
protected function getGatewayAlias(): string
25+
{
26+
return '\VTCPay';
27+
}
28+
}

tests/TestCase.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/laravel-omnipay
4+
*
5+
* @copyright (c) PHP Viet
6+
* @license [MIT](https://opensource.org/licenses/MIT)
7+
*/
8+
9+
namespace PHPViet\Laravel\Omnipay\Tests;
10+
11+
use Orchestra\Testbench\TestCase as BaseTestCase;
12+
use PHPViet\Laravel\Omnipay\OmnipayServiceProvider;
13+
use Ignited\LaravelOmnipay\LaravelOmnipayServiceProvider;
14+
15+
/**
16+
* @author Vuong Minh <vuongxuongminh@gmail.com>
17+
* @since 1.0.0
18+
*/
19+
class TestCase extends BaseTestCase
20+
{
21+
protected function getEnvironmentSetUp($app): void
22+
{
23+
$app['config']->set('laravel-omnipay', require __DIR__.'/config.php');
24+
}
25+
26+
protected function getPackageProviders($app): array
27+
{
28+
return [
29+
LaravelOmnipayServiceProvider::class,
30+
OmnipayServiceProvider::class,
31+
];
32+
}
33+
34+
protected function getPackageAliases($app): array
35+
{
36+
return [
37+
'MoMoAIO' => 'PHPViet\Laravel\Omnipay\Facades\MoMo\AllInOneGateway',
38+
'MoMoAIA' => 'PHPViet\Laravel\Omnipay\Facades\MoMo\AppInAppGateway',
39+
'MoMoPOS' => 'PHPViet\Laravel\Omnipay\Facades\MoMo\POSGateway',
40+
'MoMoQRCode' => 'PHPViet\Laravel\Omnipay\Facades\MoMo\QRCodeGateway',
41+
'OnePayDomestic' => 'PHPViet\Laravel\Omnipay\Facades\OnePay\DomesticGateway',
42+
'OnePayInternational' => 'PHPViet\Laravel\Omnipay\Facades\OnePay\InternationalGateway',
43+
'VNPay' => 'PHPViet\Laravel\Omnipay\Facades\VNPay\Gateway',
44+
'VTCPay' => 'PHPViet\Laravel\Omnipay\Facades\VTCPay\Gateway',
45+
];
46+
}
47+
}

0 commit comments

Comments
 (0)