【发布时间】:2017-06-14 14:42:10
【问题描述】:
我正在为 SOAP API 编写集成测试(代码示例如下)。
现在我遇到了一个错误,想调试我的服务器端代码(在 PhpStorm 中)。但调试器只考虑测试中的断点,而忽略服务器端代码。
好的,我大概明白为什么了:$soapClient->doSomething(...); 的调用启动了一个新的 HTTP 请求。 如何调试这个“子请求”(从 PhpUnit 的角度)?
集成测试代码:
class UserIntegrationTest extends TestCaseBase
{
const URL = "http://my-server.loc/soapapi/user/wsdl";
public static $classMap = [];
/** @var SoapClient */
private $soapClient;
/** @var ConfigurationServiceInterface */
private $config;
public function setUp()
{
parent::setUp();
$options = [
'exceptions' => true,
'login' => 'foo',
'password' => 'pwd',
'encoding' => 'utf-8',
// 'proxy_host' => '192.168.2.96',
// 'proxy_port' => '8080',
'classmap' => [],
'connection_timeout' => 5,
];
$this->soapClient = new SoapClient(self::URL, $options);
}
/**
* @test
* @group integration
*/
public function testDoSomething()
{
$options = array(
'exceptions' => true,
'login' => 'foo',
'password' => 'pwd',
'encoding' => 'utf-8',
// 'proxy_host' => '192.168.2.96',
// 'proxy_port' => '8080',
'classmap' => [],
'connection_timeout' => 5,
);
$soapClient = new SoapClient(self::URL, $options);
$message = new MyMessage();
$message->x = 1;
$message->y = 2;
$result = $soapClient->doSomething($message);
}
protected function getDataSet()
{
return new ArrayDataSet([
'users' => [
[
'id' => 1,
'username' => 'foo',
'password' => '...',
],
],
...
]);
}
}
【问题讨论】:
标签: php debugging soap phpstorm xdebug