/** * @test * @expectedException Gerencianet\Exception\GerencianetException */ public function shouldThrowExceptionForServerError() { $request = new Request($this->options); // Create a mock and queue two responses. $mock = new Mock([new Response(500, ['Content-Length' => 100])]); $request->client->getEmitter()->attach($mock); $webResponse = $request->send('POST', '/v1/authorize', ['json' => ['grant_type' => 'client_credentials']]); }
/** * @test * @expectedException Gerencianet\Exception\GerencianetException */ public function shoulThrowExceptionForServerError() { $request = new Request($this->options); // Create a mock and queue two responses. $mock = new MockHandler([new Response(500, ['Content-Length' => 100])]); $handler = HandlerStack::create($mock); $client = new Client(['handler' => $handler]); $request->client = $client; $webResponse = $request->send('POST', '/v1/authorize', ['json' => ['grant_type' => 'client_credentials']]); }