Created
April 16, 2018 12:26
-
-
Save skollro/bb45671a0aca54aed6ea21810398cfec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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