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
73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Omnipay\PayPal\Message;
|
|
|
|
use Omnipay\PayPal\Message\ExpressFetchCheckoutRequest;
|
|
use Omnipay\Tests\TestCase;
|
|
|
|
class ExpressFetchCheckoutRequestTest extends TestCase
|
|
{
|
|
/**
|
|
* @var \Omnipay\PayPal\Message\ExpressFetchCheckoutRequest
|
|
*/
|
|
private $request;
|
|
|
|
public function setUp()
|
|
{
|
|
$client = $this->getHttpClient();
|
|
|
|
$request = $this->getHttpRequest();
|
|
$request->query->set('token', 'TOKEN1234');
|
|
|
|
$this->request = new ExpressFetchCheckoutRequest($client, $request);
|
|
}
|
|
|
|
public function testGetData()
|
|
{
|
|
$this->request->setUsername('testuser');
|
|
$this->request->setPassword('testpass');
|
|
$this->request->setSignature('SIG');
|
|
|
|
$expected = array();
|
|
$expected['METHOD'] = 'GetExpressCheckoutDetails';
|
|
$expected['USER'] = 'testuser';
|
|
$expected['PWD'] = 'testpass';
|
|
$expected['SIGNATURE'] = 'SIG';
|
|
$expected['SUBJECT'] = null;
|
|
$expected['VERSION'] = ExpressCompletePurchaseRequest::API_VERSION;
|
|
$expected['TOKEN'] = 'TOKEN1234';
|
|
|
|
$this->assertEquals($expected, $this->request->getData());
|
|
}
|
|
|
|
public function testGetDataTokenOverride()
|
|
{
|
|
$this->request->setToken('TOKEN2000');
|
|
|
|
$data = $this->request->getData();
|
|
|
|
$this->assertSame('TOKEN2000', $data['TOKEN']);
|
|
}
|
|
|
|
public function testSendSuccess()
|
|
{
|
|
$this->setMockHttpResponse('ExpressFetchCheckoutSuccess.txt');
|
|
|
|
$response = $this->request->send();
|
|
$this->assertFalse($response->isPending());
|
|
$this->assertTrue($response->isSuccessful());
|
|
$this->assertFalse($response->isRedirect());
|
|
}
|
|
|
|
public function testSendFailure()
|
|
{
|
|
$this->setMockHttpResponse('ExpressFetchCheckoutFailure.txt');
|
|
|
|
$response = $this->request->send();
|
|
$this->assertFalse($response->isPending());
|
|
$this->assertFalse($response->isSuccessful());
|
|
$this->assertFalse($response->isRedirect());
|
|
$this->assertSame('The amount exceeds the maximum amount for a single transaction.', $response->getMessage());
|
|
}
|
|
}
|