mirror of
https://gitee.com/yansongda/pay.git
synced 2024-11-30 03:07:38 +08:00
tests
This commit is contained in:
parent
e320e5abc0
commit
b11cd77422
56
tests/Plugins/ParserPluginTest.php
Normal file
56
tests/Plugins/ParserPluginTest.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugins;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Yansongda\Pay\Contract\ParserInterface;
|
||||
use Yansongda\Pay\Exception\InvalidConfigException;
|
||||
use Yansongda\Pay\Parser\ArrayParser;
|
||||
use Yansongda\Pay\Parser\NoHttpRequestParser;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\ParserPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\Stubs\Packer\FooPackerStub;
|
||||
|
||||
class ParserPluginTest extends TestCase
|
||||
{
|
||||
public function testPackerWrong()
|
||||
{
|
||||
self::expectException(InvalidConfigException::class);
|
||||
self::expectExceptionCode(InvalidConfigException::INVALID_PACKER);
|
||||
|
||||
Pay::config([]);
|
||||
|
||||
$rocket = new Rocket();
|
||||
$rocket->setDirection(FooPackerStub::class);
|
||||
|
||||
$parser = new ParserPlugin();
|
||||
$parser->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
|
||||
public function testPackerDefault()
|
||||
{
|
||||
Pay::config([]);
|
||||
Pay::set(ParserInterface::class, NoHttpRequestParser::class);
|
||||
|
||||
$rocket = new Rocket();
|
||||
|
||||
$parser = new ParserPlugin();
|
||||
$result = $parser->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
self::assertSame($rocket, $result);
|
||||
}
|
||||
|
||||
public function testPackerObject()
|
||||
{
|
||||
Pay::config([]);
|
||||
Pay::set(ParserInterface::class, new NoHttpRequestParser());
|
||||
|
||||
$rocket = new Rocket();
|
||||
|
||||
$parser = new ParserPlugin();
|
||||
$result = $parser->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
self::assertSame($rocket, $result);
|
||||
}
|
||||
}
|
7
tests/Stubs/Packer/FooPackerStub.php
Normal file
7
tests/Stubs/Packer/FooPackerStub.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Stubs\Packer;
|
||||
|
||||
class FooPackerStub
|
||||
{
|
||||
}
|
Loading…
Reference in New Issue
Block a user