1
0

repo initialized with test cases

This commit is contained in:
moizgillani
2024-09-06 15:38:17 +05:00
parent c9cb1ad04a
commit b20aa829db
754 changed files with 76684 additions and 1 deletions

View File

@@ -0,0 +1,242 @@
<?php
declare(strict_types=1);
/*
* PayPalRESTAPIsLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
namespace PayPalRESTAPIsLib\Tests\UnitTests;
use PayPalRESTAPIsLib\Controllers\VaultController;
use PayPalRESTAPIsLib\Models\Builders\PaymentTokenRequestBuilder;
use PayPalRESTAPIsLib\Models\Builders\PaymentTokenRequestPaymentSourceBuilder;
use PayPalRESTAPIsLib\Models\Builders\SetupTokenRequestBuilder;
use PayPalRESTAPIsLib\Models\Builders\SetupTokenRequestPaymentSourceBuilder;
use PayPalRESTAPIsLib\Models\Builders\VaultTokenRequestBuilder;
use PayPalRESTAPIsLib\Models\TokenType;
use PayPalRESTAPIsLib\Tests\Controllers\BaseTestController;
class VaultControllerTest extends BaseTestController
{
/**
* @var VaultController OrdersController instance
*/
protected static $controller;
private const NON_EXISTENT_SETUP_TOKEN_ID = 'setup-1';
private const NON_EXISTENT_PAYMENT_TOKEN_ID = 'payment-1';
private const NON_EXISTENT_CUSTOMER_ID = 'customer-1';
private const INVALID_ID = "'dw";
/**
* Setup test class
*/
public static function setUpBeforeClass(): void
{
self::$controller = parent::getClient()->getVaultController();
}
public function testSetupTokensCreateWithStatus400()
{
// Parameters for the API call
$request = [
'payPalRequestId' => '',
'body' => SetupTokenRequestBuilder::init(
SetupTokenRequestPaymentSourceBuilder::init()->build()
)->build()
];
// Perform API call
$result = self::$controller->setupTokensCreate($request);
$headers = [];
$headers['Content-Type'] = ['application/json', true];
// Assert result with expected response
$this->assertTrue($result->isError());
$this->newTestCase($result->getResult())
->expectStatus(400)
->allowExtraHeaders()
->expectHeaders($headers)
->assert();
}
public function testPaymentTokensCreateWithStatus404()
{
// Parameters for the API call
$request = [
'body' => PaymentTokenRequestBuilder::init(
PaymentTokenRequestPaymentSourceBuilder::init()->build()
)->build(),
'payPalRequestId' => '',
];
// Perform API call
$result = self::$controller->paymentTokensCreate($request);
$headers = [];
$headers['Content-Type'] = ['application/json', true];
// Assert result with expected response
$this->assertTrue($result->isError());
$this->newTestCase($result->getResult())
->expectStatus(404)
->allowExtraHeaders()
->expectHeaders($headers)
->assert();
}
public function testPaymentTokensCreateWithStatus400()
{
// Parameters for the API call
$request = [
'body' => PaymentTokenRequestBuilder::init(
PaymentTokenRequestPaymentSourceBuilder::init()
->token(VaultTokenRequestBuilder::init(self::INVALID_ID, TokenType::SETUP_TOKEN)->build())
->build()
)->build(),
'payPalRequestId' => '',
];
// Perform API call
$result = self::$controller->paymentTokensCreate($request);
$headers = [];
$headers['Content-Type'] = ['application/json', true];
// Assert result with expected response
$this->assertTrue($result->isError());
$this->newTestCase($result->getResult())
->expectStatus(400)
->allowExtraHeaders()
->expectHeaders($headers)
->assert();
}
public function testSetupTokensGetWithStatus404()
{
// Perform API call
$result = self::$controller->setupTokensGet(self::NON_EXISTENT_SETUP_TOKEN_ID);
$headers = [];
$headers['Content-Type'] = ['application/json', true];
// Assert result with expected response
$this->assertTrue($result->isError());
$this->newTestCase($result->getResult())
->expectStatus(404)
->allowExtraHeaders()
->expectHeaders($headers)
->assert();
}
public function testSetupTokensGetWithStatus400()
{
// Perform API call
$result = self::$controller->setupTokensGet(self::INVALID_ID);
$headers = [];
$headers['Content-Type'] = ['application/json', true];
// Assert result with expected response
$this->assertTrue($result->isError());
$this->newTestCase($result->getResult())
->expectStatus(400)
->allowExtraHeaders()
->expectHeaders($headers)
->assert();
}
public function testPaymentTokensGetWithStatus404()
{
// Perform API call
$result = self::$controller->paymentTokensGet(self::NON_EXISTENT_PAYMENT_TOKEN_ID);
$headers = [];
$headers['Content-Type'] = ['application/json', true];
// Assert result with expected response
$this->assertTrue($result->isError());
$this->newTestCase($result->getResult())
->expectStatus(404)
->allowExtraHeaders()
->expectHeaders($headers)
->assert();
}
public function testPaymentTokensGetWithStatus400()
{
// Perform API call
$result = self::$controller->paymentTokensGet(self::NON_EXISTENT_PAYMENT_TOKEN_ID);
$headers = [];
$headers['Content-Type'] = ['application/json', true];
// Assert result with expected response
$this->assertTrue($result->isError());
$this->newTestCase($result->getResult())
->expectStatus(404)
->allowExtraHeaders()
->expectHeaders($headers)
->assert();
}
public function testCustomerPaymentTokensGetWithStatus404()
{
// Parameters for the API call
$request = [
'customerId' => self::NON_EXISTENT_CUSTOMER_ID,
'pageSize' => 5,
'page' => 1,
'totalRequired' => false,
];
// Perform API call
$result = self::$controller->customerPaymentTokensGet($request);
$headers = [];
$headers['Content-Type'] = ['application/json', true];
// Assert result with expected response
$this->assertTrue($result->isError());
$this->newTestCase($result->getResult())
->expectStatus(404)
->allowExtraHeaders()
->expectHeaders($headers)
->assert();
}
public function testCustomerPaymentTokensGetWithStatus400()
{
// Parameters for the API call
$request = [
'customerId' => self::INVALID_ID,
'pageSize' => 5,
'page' => 1,
'totalRequired' => false,
];
// Perform API call
$result = self::$controller->customerPaymentTokensGet($request);
$headers = [];
$headers['Content-Type'] = ['application/json', true];
// Assert result with expected response
$this->assertTrue($result->isError());
$this->newTestCase($result->getResult())
->expectStatus(400)
->allowExtraHeaders()
->expectHeaders($headers)
->assert();
}
public function testPaymentTokensDeleteWithStatus204()
{
// Perform API call
$result = self::$controller->paymentTokensDelete(self::NON_EXISTENT_PAYMENT_TOKEN_ID);
// Assert result with expected response
$this->assertTrue($result->isSuccess());
$this->newTestCase($result->getResult())
->expectStatus(204)
->assert();
}
}