mirror of
https://gitee.com/yansongda/pay.git
synced 2024-11-30 03:07:38 +08:00
tests
This commit is contained in:
parent
2812d6817a
commit
0e74e6146f
@ -6,12 +6,15 @@ namespace Yansongda\Pay\Plugin\Alipay\Data;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Pay\Contract\PluginInterface;
|
||||
use Yansongda\Pay\Logger;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class BillEreceiptApplyPlugin implements PluginInterface
|
||||
{
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::info('[alipay][BillEreceiptApplyPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$rocket->mergePayload([
|
||||
'method' => 'alipay.data.bill.ereceipt.apply',
|
||||
'biz_content' => array_merge(
|
||||
@ -22,6 +25,8 @@ class BillEreceiptApplyPlugin implements PluginInterface
|
||||
),
|
||||
]);
|
||||
|
||||
Logger::info('[alipay][BillEreceiptApplyPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,15 @@ namespace Yansongda\Pay\Plugin\Alipay\Ebpp;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Pay\Contract\PluginInterface;
|
||||
use Yansongda\Pay\Logger;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class PdeductPayPlugin implements PluginInterface
|
||||
{
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::info('[alipay][PdeductPayPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$rocket->mergePayload([
|
||||
'method' => 'alipay.ebpp.pdeduct.pay',
|
||||
'biz_content' => array_merge(
|
||||
@ -22,6 +25,8 @@ class PdeductPayPlugin implements PluginInterface
|
||||
),
|
||||
]);
|
||||
|
||||
Logger::info('[alipay][PdeductPayPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,15 @@ namespace Yansongda\Pay\Plugin\Alipay\Ebpp;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Pay\Contract\PluginInterface;
|
||||
use Yansongda\Pay\Logger;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class PdeductSignAddPlugin implements PluginInterface
|
||||
{
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::info('[alipay][PdeductSignAddPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$rocket->mergePayload([
|
||||
'method' => 'alipay.ebpp.pdeduct.sign.add',
|
||||
'biz_content' => array_merge(
|
||||
@ -24,6 +27,8 @@ class PdeductSignAddPlugin implements PluginInterface
|
||||
),
|
||||
]);
|
||||
|
||||
Logger::info('[alipay][PdeductSignAddPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,15 @@ namespace Yansongda\Pay\Plugin\Alipay\Ebpp;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Pay\Contract\PluginInterface;
|
||||
use Yansongda\Pay\Logger;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class PdeductSignCancelPlugin implements PluginInterface
|
||||
{
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::info('[alipay][PdeductSignCancelPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$rocket->mergePayload([
|
||||
'method' => 'alipay.ebpp.pdeduct.sign.cancel',
|
||||
'biz_content' => array_merge(
|
||||
@ -22,6 +25,8 @@ class PdeductSignCancelPlugin implements PluginInterface
|
||||
),
|
||||
]);
|
||||
|
||||
Logger::info('[alipay][PdeductSignCancelPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ class LaunchPlugin implements PluginInterface
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::info('[alipay][LaunchPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
/* @var Rocket $rocket */
|
||||
$rocket = $next($rocket);
|
||||
|
||||
Logger::info('[alipay][LaunchPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
if (should_do_http_request($rocket)) {
|
||||
$this->verifySign($rocket);
|
||||
|
||||
|
@ -22,11 +22,11 @@ class LaunchPlugin implements PluginInterface
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::info('[wechat][LaunchPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
/* @var Rocket $rocket */
|
||||
$rocket = $next($rocket);
|
||||
|
||||
Logger::info('[wechat][LaunchPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
if (should_do_http_request($rocket)) {
|
||||
verify_wechat_sign($rocket->getDestinationOrigin(), $rocket->getParams());
|
||||
|
||||
|
@ -23,11 +23,11 @@ class InvokePrepayPlugin implements PluginInterface
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::info('[wechat][InvokePrepayPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
/* @var Rocket $rocket */
|
||||
$rocket = $next($rocket);
|
||||
|
||||
Logger::info('[wechat][InvokePrepayPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$prepayId = $rocket->getPayload()->get('prepay_id');
|
||||
|
||||
if (is_null($prepayId)) {
|
||||
|
@ -3,9 +3,8 @@
|
||||
namespace Yansongda\Pay\Tests\Plugin\Alipay;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Yansongda\Pay\Parser\ResponseParser;
|
||||
use Yansongda\Pay\Plugin\Alipay\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\Stubs\Plugin\AlipayGeneralPluginStub;
|
||||
|
||||
class GeneralPayPluginTest extends TestCase
|
||||
{
|
||||
@ -14,7 +13,7 @@ class GeneralPayPluginTest extends TestCase
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([]);
|
||||
|
||||
$plugin = new FooPlugin();
|
||||
$plugin = new AlipayGeneralPluginStub();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
@ -22,10 +21,3 @@ class GeneralPayPluginTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
class FooPlugin extends GeneralPlugin
|
||||
{
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'yansongda';
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ use Yansongda\Pay\Parser\NoHttpRequestParser;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\ParserPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\Stubs\FooPackerStub;
|
||||
|
||||
class ParserPluginTest extends TestCase
|
||||
{
|
||||
@ -52,7 +53,3 @@ class ParserPluginTest extends TestCase
|
||||
self::assertSame($rocket, $result);
|
||||
}
|
||||
}
|
||||
|
||||
class FooPackerStub
|
||||
{
|
||||
}
|
||||
|
30
tests/Plugin/Wechat/GeneralPluginTest.php
Normal file
30
tests/Plugin/Wechat/GeneralPluginTest.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\Stubs\Plugin\WechatGeneralPluginStub;
|
||||
|
||||
class GeneralPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([]);
|
||||
|
||||
$plugin = new WechatGeneralPluginStub();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
|
||||
self::assertInstanceOf(RequestInterface::class, $radar);
|
||||
self::assertEquals('POST', $radar->getMethod());
|
||||
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'yansongda/pay'), $radar->getUri());
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ use Yansongda\Pay\Plugin\Alipay\PreparePlugin;
|
||||
use Yansongda\Pay\Plugin\Alipay\RadarPlugin;
|
||||
use Yansongda\Pay\Plugin\Alipay\SignPlugin;
|
||||
use Yansongda\Pay\Plugin\ParserPlugin;
|
||||
use Yansongda\Pay\Tests\Stubs\Plugin\FooPluginStub;
|
||||
|
||||
class AlipayTest extends TestCase
|
||||
{
|
||||
@ -224,11 +225,3 @@ class AlipayTest extends TestCase
|
||||
), Pay::alipay()->mergeCommonPlugins($plugins));
|
||||
}
|
||||
}
|
||||
|
||||
class FooPluginStub
|
||||
{
|
||||
}
|
||||
|
||||
class FooShortcut
|
||||
{
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ use Yansongda\Pay\Plugin\ParserPlugin;
|
||||
use Yansongda\Pay\Plugin\Wechat\LaunchPlugin;
|
||||
use Yansongda\Pay\Plugin\Wechat\PreparePlugin;
|
||||
use Yansongda\Pay\Plugin\Wechat\SignPlugin;
|
||||
use Yansongda\Pay\Tests\Stubs\Plugin\FooPluginStub;
|
||||
|
||||
class WechatTest extends TestCase
|
||||
{
|
||||
|
7
tests/Stubs/FooPackerStub.php
Normal file
7
tests/Stubs/FooPackerStub.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Stubs;
|
||||
|
||||
class FooPackerStub
|
||||
{
|
||||
}
|
13
tests/Stubs/Plugin/AlipayGeneralPluginStub.php
Normal file
13
tests/Stubs/Plugin/AlipayGeneralPluginStub.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Stubs\Plugin;
|
||||
|
||||
use Yansongda\Pay\Plugin\Alipay\GeneralPlugin;
|
||||
|
||||
class AlipayGeneralPluginStub extends GeneralPlugin
|
||||
{
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'yansongda';
|
||||
}
|
||||
}
|
7
tests/Stubs/Plugin/FooPluginStub.php
Normal file
7
tests/Stubs/Plugin/FooPluginStub.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Stubs\Plugin;
|
||||
|
||||
class FooPluginStub
|
||||
{
|
||||
}
|
18
tests/Stubs/Plugin/WechatGeneralPluginStub.php
Normal file
18
tests/Stubs/Plugin/WechatGeneralPluginStub.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Stubs\Plugin;
|
||||
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class WechatGeneralPluginStub extends GeneralPlugin
|
||||
{
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
}
|
||||
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
return 'yansongda/pay';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user