Tentei criar o seguinte teste
public function test_should_return_400_if_no_name_is_provided()
{
$this->expectError();
$this->sut = new SignUpController();
$body = [
'body' => [
'email' => 'any@email.com',
'password' => 'any_password',
'passwordConfirmation' => 'any_password'
]
];
$this->withHeaders();
$psr17Factory = new Psr17Factory();
$creator = new ServerRequestCreator(
$psr17Factory,
$psr17Factory,
$psr17Factory,
$psr17Factory
);
$request = $creator->fromGlobals();
$request->withBody($psr17Factory->createStream(json_encode($body)));
$response = $this->sut->handle($request);
}
para o nosso controller em questão , porém ao tentar pegar os valores na controller
public function handle(ServerRequestInterface $httpRequest): ResponseInterface
{
var_dump($httpRequest->getBody()->getContents()); exit;
}
recebo o seguinte
Sign Up Controller
✘ Should return 400 if no name is provided
┐
├ PHPUnit\Framework\Exception: string(0) ""
O que estou errando? Obrigado!