How to debug phpunit ? How to force display logs of phpunit ?
Introduction
See how to concretely, force an output message during a phpunit execution
fwrite(STDERR, "TEST");
Example of a use case in the code
/**
* testArtworkSetsAssignmentInfoValidProductUUIDAction
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @author David Raleche
* @version 08-26-2020
*/
public function testArtworkSetsAssignmentInfoValidProductUUIDAction()
{
$payload = array(
"order_id" => "1234560",
"customer_id" => "12345",
"product_info" => [
"product_uuid" => "12345"
]
);
$jsonPayload = json_encode($payload);
$artwork_set_uuid = ArtworkToolService::postArtworkSets($jsonPayload, 12345);
/** ------------------------- GET ------------------------------------------------- */
$headers = [
'Authorization' => QATemplate::$getKey,
];
$url = '/v1/artwork-info/' . $artwork_set_uuid . '/assignment-info';
$response = QATemplate::$http->request(
'GET',
$url,
[
'verify' => false,
'headers' => $headers,
'http_errors' => false,
]
);
fwrite(STDERR, (string) $url);
fwrite(STDERR, (string)$response->getStatusCode());
$this->assertEquals(422, $response->getStatusCode());
$contentType = $response->getHeaders()["Content-Type"][0];
$this->assertEquals("application/json", $contentType);
/* test for output */
$body = $response->getBody();
$jsonBody = (array)json_decode((string)$body);
fwrite(STDERR, $jsonBody['message']);
$this->assertEquals('Product UUID has not a valid format :12345', $jsonBody['message']);
}
See output below
Comments