Changeset View
Changeset View
Standalone View
Standalone View
src/tests/StripeMockClient.php
<?php | <?php | ||||
namespace Tests; | namespace Tests; | ||||
use Stripe as StripeAPI; | use Stripe as StripeAPI; | ||||
class StripeMockClient implements StripeAPI\HttpClient\ClientInterface | class StripeMockClient implements StripeAPI\HttpClient\ClientInterface | ||||
{ | { | ||||
private $responses = []; | private $responses = []; | ||||
public function request($method, $absUrl, $headers, $params, $hasFile) | public function request($method, $absUrl, $headers, $params, $hasFile) | ||||
{ | { | ||||
if (empty($this->responses)) { | |||||
throw new \Exception("StripeMockClient: Missing response for $absUrl."); | |||||
} | |||||
$response = array_shift($this->responses); | $response = array_shift($this->responses); | ||||
return $response; | return $response; | ||||
} | } | ||||
public function addResponse($body, $code = 200, $headers = []) | public function addResponse($body, $code = 200, $headers = []) | ||||
{ | { | ||||
$this->responses[] = [$body, $code, $headers]; | $this->responses[] = [$body, $code, $headers]; | ||||
} | } | ||||
} | } |