Skip to content

Commit

Permalink
feat: 新增单元测试
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghaojie committed Jun 17, 2024
1 parent 14a1b24 commit 0d9d31d
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 8 deletions.
9 changes: 1 addition & 8 deletions tests/Provider/EpayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ public function testShortcutNotFound()
Pay::epay()->foo();
}

public function testShortcutIncompatible()
{
self::expectException(InvalidParamsException::class);
self::expectExceptionCode(Exception::PARAMS_SHORTCUT_INVALID);

Pay::wechat()->foo();
}

public function testMergeCommonPlugins()
{
Pay::config([]);
Expand All @@ -51,6 +43,7 @@ public function testMergeCommonPlugins()
[AddPayloadSignPlugin::class, AddRadarPlugin::class, VerifySignaturePlugin::class, ResponsePlugin::class, ParserPlugin::class],
), Pay::epay()->mergeCommonPlugins($plugins));
}

public function testSuccess()
{
$result = Pay::epay()->success();
Expand Down
40 changes: 40 additions & 0 deletions tests/Shortcut/Epay/CancelShortcutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Yansongda\Pay\Tests\Shortcut\Epay;

use Yansongda\Artful\Plugin\ParserPlugin;
use Yansongda\Pay\Plugin\Epay\AddPayloadSignPlugin;
use Yansongda\Pay\Plugin\Epay\AddRadarPlugin;
use Yansongda\Pay\Plugin\Epay\Pay\Scan\CancelPlugin;
use Yansongda\Pay\Plugin\Epay\ResponsePlugin;
use Yansongda\Pay\Plugin\Epay\StartPlugin;
use Yansongda\Pay\Plugin\Epay\VerifySignaturePlugin;
use Yansongda\Pay\Shortcut\Epay\CancelShortcut;
use Yansongda\Pay\Tests\TestCase;

class CancelShortcutTest extends TestCase
{

protected CancelShortcut $plugin;

protected function setUp(): void
{
parent::setUp();

$this->plugin = new CancelShortcut();
}


public function testDefault()
{
self::assertEquals([
StartPlugin::class,
CancelPlugin::class,
AddPayloadSignPlugin::class,
AddRadarPlugin::class,
VerifySignaturePlugin::class,
ResponsePlugin::class,
ParserPlugin::class,
], $this->plugin->getPlugins([]));
}
}
39 changes: 39 additions & 0 deletions tests/Shortcut/Epay/QueryShortcutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Yansongda\Pay\Tests\Shortcut\Epay;

use Yansongda\Artful\Plugin\ParserPlugin;
use Yansongda\Pay\Plugin\Epay\AddPayloadSignPlugin;
use Yansongda\Pay\Plugin\Epay\AddRadarPlugin;
use Yansongda\Pay\Plugin\Epay\Pay\Scan\QueryPlugin;
use Yansongda\Pay\Plugin\Epay\ResponsePlugin;
use Yansongda\Pay\Plugin\Epay\StartPlugin;
use Yansongda\Pay\Plugin\Epay\VerifySignaturePlugin;
use Yansongda\Pay\Shortcut\Epay\QueryShortcut;
use Yansongda\Pay\Tests\TestCase;

class QueryShortcutTest extends TestCase
{

protected QueryShortcut $plugin;

protected function setUp(): void
{
parent::setUp();

$this->plugin = new QueryShortcut();
}

public function testDefault()
{
self::assertEquals([
StartPlugin::class,
QueryPlugin::class,
AddPayloadSignPlugin::class,
AddRadarPlugin::class,
VerifySignaturePlugin::class,
ResponsePlugin::class,
ParserPlugin::class,
], $this->plugin->getPlugins([]));
}
}
38 changes: 38 additions & 0 deletions tests/Shortcut/Epay/RefundShortcutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Yansongda\Pay\Tests\Shortcut\Epay;

use Yansongda\Artful\Plugin\ParserPlugin;
use Yansongda\Pay\Plugin\Epay\AddPayloadSignPlugin;
use Yansongda\Pay\Plugin\Epay\AddRadarPlugin;
use Yansongda\Pay\Plugin\Epay\Pay\Scan\RefundPlugin;
use Yansongda\Pay\Plugin\Epay\ResponsePlugin;
use Yansongda\Pay\Plugin\Epay\StartPlugin;
use Yansongda\Pay\Plugin\Epay\VerifySignaturePlugin;
use Yansongda\Pay\Shortcut\Epay\RefundShortcut;
use Yansongda\Pay\Tests\TestCase;

class RefundShortcutTest extends TestCase
{
protected RefundShortcut $plugin;

protected function setUp(): void
{
parent::setUp();

$this->plugin = new RefundShortcut();
}

public function testDefault()
{
self::assertEquals([
StartPlugin::class,
RefundPlugin::class,
AddPayloadSignPlugin::class,
AddRadarPlugin::class,
VerifySignaturePlugin::class,
ResponsePlugin::class,
ParserPlugin::class,
], $this->plugin->getPlugins([]));
}
}
38 changes: 38 additions & 0 deletions tests/Shortcut/Epay/ScanShortcutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Yansongda\Pay\Tests\Shortcut\Epay;

use Yansongda\Artful\Plugin\ParserPlugin;
use Yansongda\Pay\Plugin\Epay\AddPayloadSignPlugin;
use Yansongda\Pay\Plugin\Epay\AddRadarPlugin;
use Yansongda\Pay\Plugin\Epay\Pay\Scan\PrepayPlugin;
use Yansongda\Pay\Plugin\Epay\ResponsePlugin;
use Yansongda\Pay\Plugin\Epay\StartPlugin;
use Yansongda\Pay\Plugin\Epay\VerifySignaturePlugin;
use Yansongda\Pay\Shortcut\Epay\ScanShortcut;
use Yansongda\Pay\Tests\TestCase;

class ScanShortcutTest extends TestCase
{
protected ScanShortcut $plugin;

protected function setUp(): void
{
parent::setUp();

$this->plugin = new ScanShortcut();
}

public function testDefault()
{
self::assertEquals([
StartPlugin::class,
PrepayPlugin::class,
AddPayloadSignPlugin::class,
AddRadarPlugin::class,
VerifySignaturePlugin::class,
ResponsePlugin::class,
ParserPlugin::class,
], $this->plugin->getPlugins([]));
}
}

0 comments on commit 0d9d31d

Please sign in to comment.