1
在PHPUnit測試中使用Guzzle MockPlugin。我發現無論我做什麼,響應內容主體都是空的。Guzzle MockPlugin未響應內容正文
我做錯了什麼,或者它是一個錯誤?
測試設置
$client = new Client();
$plugin = new MockPlugin();
$plugin->addResponse(new Response(200, null, "This is never sent..."));
$client->addSubscriber($plugin);
$this->httpClientFactoryMock
->expects($this->any())
->method('getClient')
->will($this->returnValue($client));
方法測試
$client = $this->httpClientFactory->getClient();
$request = $client->post($this->url, null, $content->asXML());
$response = $request->send();
$response->body
沒有"This is never sent..."
任何地方:( 不過,我可以把東西放在頭,所以我確保插件正在工作,至少在某種程度上。