-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
I have got a simple test for a gateway. Everything goes fine while the test is not ran in a separateProcess
public function testSingle() {
$this->http->mock
->when()
->then()
->callback(
function (\Symfony\Component\HttpFoundation\Response $response) {
$response->setContent(file_get_contents(__DIR__ . '/../../xml/single.xml'))->setStatusCode(
200
);
}
)
->end();
$this->http->setUp();
//initialize gateway
$response = $gateway->byName('my-name')->query();
$rows = $response->getRows();
self::assertCount(1, $rows);
}
But If I add the runInSeparateProcess annotation, then tearDownHttpMock
fails
/**
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testSingle() {
//my code
}
$server->getIncrementalErrorOutput()
returns [Wed Apr 3 16:52:26 2019] Failed to listen on 127.0.0.1:33371 (reason: Address already in use)
As workaround I override the method into my test class
protected function tearDownHttpMock()
{
if (!$this->http) {
return;
}
//just skipping to make test work
if($this->isInIsolation()){
return;
}
$http = $this->http;
$this->http = null;
$http->each(
function (HttpMockFacade $facade) {
$this->assertSame(
'',
(string) $facade->server->getIncrementalErrorOutput(),
'HTTP mock server standard error output should be empty'
);
}
);
}
But I guess if there is another (better/proper) way to do this
DavidePastore
Metadata
Metadata
Assignees
Labels
No labels