Skip to content

Instantly share code, notes, and snippets.

@skollro
Created April 16, 2018 12:26
Show Gist options
  • Save skollro/bb45671a0aca54aed6ea21810398cfec to your computer and use it in GitHub Desktop.
Save skollro/bb45671a0aca54aed6ea21810398cfec to your computer and use it in GitHub Desktop.
<?php
class FakeSoapClient extends \SoapClient
{
protected $response;
protected $customizer;
public static function wsdl($wsdl)
{
return new self($wsdl);
}
public function withResponse($response, $customizer = null)
{
$this->customizer = $customizer;
$this->response = $response;
return $this;
}
public function __doRequest($request, $location, $action, $version, $one_way = null)
{
return $this->response;
}
public function __call($name, $arguments)
{
$response = parent::__call($name, $arguments);
if (is_callable(($this->customizer))) {
($this->customizer)($response);
}
return $response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment