Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yansongda committed Feb 29, 2024
1 parent d16485a commit f5a758b
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions tests/Plugin/Wechat/ResponsePluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace Yansongda\Pay\Tests\Plugin\Wechat;

use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\ServerRequest;
use Yansongda\Artful\Direction\OriginResponseDirection;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Artful\Exception\InvalidResponseException;
use Yansongda\Pay\Plugin\Wechat\ResponsePlugin;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Plugin\Wechat\ResponsePlugin;
use Yansongda\Pay\Tests\TestCase;
use Yansongda\Supports\Collection;

Expand All @@ -28,40 +27,24 @@ public function testOriginalResponseDestination()
$destination = new Response();

$rocket = new Rocket();
$rocket->setDirection(OriginResponseDirection::class);
$rocket->setDestination($destination);
$rocket->setDestinationOrigin(new ServerRequest('POST', 'http://localhost'));
$rocket->setDestinationOrigin($destination);
$rocket->setDestination(new Collection());

$result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; });

self::assertSame($destination, $result->getDestination());
self::assertInstanceOf(Collection::class, $result->getDestination());
}

public function testOriginalResponseCodeErrorDestination()
{
$destination = new Response(500);

$rocket = new Rocket();
$rocket->setDirection(OriginResponseDirection::class);
$rocket->setDestination($destination);
$rocket->setDestinationOrigin(new ServerRequest('POST', 'http://localhost'));
$rocket->setDestinationOrigin($destination);

self::expectException(InvalidResponseException::class);
self::expectExceptionCode(Exception::RESPONSE_CODE_WRONG);

$this->plugin->assembly($rocket, function ($rocket) { return $rocket; });
}

public function testCollectionDestination()
{
$destination = new Collection();

$rocket = new Rocket();
$rocket->setDestination($destination);
$rocket->setDestinationOrigin(new ServerRequest('POST', 'http://localhost'));

$result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; });

self::assertSame($destination, $result->getDestination());
}
}

0 comments on commit f5a758b

Please sign in to comment.