All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
72 lines
2.2 KiB
PHP
72 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Omnipay\Stripe\Message\Transfers;
|
|
|
|
use Guzzle\Http\Message\Response;
|
|
use Omnipay\Tests\TestCase;
|
|
|
|
class CreateTransferReversalRequestTest extends TestCase
|
|
{
|
|
/**
|
|
* @var CreateTransferReversalRequest
|
|
*/
|
|
protected $request;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $mockDir;
|
|
|
|
public function setUp()
|
|
{
|
|
$this->mockDir = __DIR__.'/../../Mock/Transfers';
|
|
$this->request = new CreateTransferReversalRequest($this->getHttpClient(), $this->getHttpRequest());
|
|
$this->request->initialize(
|
|
array(
|
|
'transferReference' => 'REVERSAL_ID',
|
|
'amount' => '12.00',
|
|
'description' => 'Reversing Order 42',
|
|
'metadata' => array(
|
|
'foo' => 'bar',
|
|
),
|
|
)
|
|
);
|
|
}
|
|
|
|
public function testGetData()
|
|
{
|
|
$data = $this->request->getData();
|
|
|
|
$this->assertSame(1200, $data['amount']);
|
|
$this->assertSame('Reversing Order 42', $data['description']);
|
|
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
|
|
}
|
|
|
|
public function testSendSuccess()
|
|
{
|
|
$this->setMockHttpResponse(
|
|
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/CreateTransferReversalRequestSuccess.txt')))
|
|
);
|
|
|
|
/** @var \Omnipay\Stripe\Message\Response $response */
|
|
$response = $this->request->send();
|
|
|
|
$this->assertTrue($response->isSuccessful());
|
|
$this->assertFalse($response->isRedirect());
|
|
$this->assertSame('trr_1ARKQ22eZvKYlo2Cv5APdtKF', $response->getTransferReversalReference());
|
|
$this->assertNull($response->getMessage());
|
|
}
|
|
|
|
public function testSendFailure()
|
|
{
|
|
$this->setMockHttpResponse(
|
|
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/FetchTransferReversalFailure.txt')))
|
|
);
|
|
$response = $this->request->send();
|
|
|
|
$this->assertFalse($response->isSuccessful());
|
|
$this->assertFalse($response->isRedirect());
|
|
$this->assertSame('No such transfer reversal: trr_1ARKQ22eZvKYlo2Cv5APdtKF', $response->getMessage());
|
|
}
|
|
}
|