/home/kueuepay/public_html/vendor/srmklive/paypal/tests/Unit/Client/SubscriptionsTest.php
<?php
namespace Srmklive\PayPal\Tests\Unit\Client;
use GuzzleHttp\Utils;
use PHPUnit\Framework\TestCase;
use Srmklive\PayPal\Tests\MockClientClasses;
use Srmklive\PayPal\Tests\MockRequestPayloads;
use Srmklive\PayPal\Tests\MockResponsePayloads;
class SubscriptionsTest extends TestCase
{
use MockClientClasses;
use MockRequestPayloads;
use MockResponsePayloads;
/** @test */
public function it_can_create_a_subscription()
{
$expectedResponse = $this->mockCreateSubscriptionResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->mockCreateSubscriptionParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_update_a_subscription()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->mockUpdateSubscriptionParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_show_details_for_a_subscription()
{
$expectedResponse = $this->mockGetSubscriptionDetailsResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_activate_a_subscription()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/activate';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->mockActivateSubscriptionParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_cancel_a_subscription()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/cancel';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->mockCancelSubscriptionParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_suspend_a_subscription()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/suspend';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->mockSuspendSubscriptionParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_capture_payment_for_a_subscription()
{
$expectedResponse = '';
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/capture';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->mockCaptureSubscriptionPaymentParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_update_quantity_or_product_for_a_subscription()
{
$expectedResponse = $this->mockUpdateSubscriptionItemsResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/revise';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
'json' => $this->mockUpdateSubscriptionItemsParams(),
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
}
/** @test */
public function it_can_list_transactions_for_a_subscription()
{
$expectedResponse = $this->mockListSubscriptionTransactionsResponse();
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/transactions?start_time=2018-01-21T07:50:20.940Z&end_time=2018-08-21T07:50:20.940Z';
$expectedParams = [
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Authorization' => 'Bearer some-token',
],
];
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get');
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true));
}
}
Run Command [Bypass]
Run Command
User Login
top
In the digital age, privacy concerns have become increasingly paramount, prompting the European Union to enact the General Data Protection Regulation (GDPR) in 2018. Among its many provisions, GDPR sets strict guidelines for the collection and processing of personal data, including the use of cookies on websites. Privacy Policy
Allow
Decline