/** * @covers Imbo\Http\Response\Response::setError */ public function testUpdatesResponseWhenSettingAnErrorModel() { $message = 'You wronged'; $code = 404; $imboErrorCode = 123; $date = new DateTime('@1361614522', new DateTimeZone('UTC')); $error = $this->getMock('Imbo\\Model\\Error'); $error->expects($this->once())->method('getHttpCode')->will($this->returnValue($code)); $error->expects($this->once())->method('getImboErrorCode')->will($this->returnValue($imboErrorCode)); $error->expects($this->once())->method('getErrorMessage')->will($this->returnValue($message)); $error->expects($this->once())->method('getDate')->will($this->returnValue($date)); $this->response->headers->set('ETag', '"sometag"'); $this->response->setLastModified(new DateTime('now', new DateTimeZone('UTC'))); $this->response->setError($error); $this->assertSame($code, $this->response->getStatusCode()); $this->assertSame($message, $this->response->headers->get('X-Imbo-Error-Message')); $this->assertSame($imboErrorCode, $this->response->headers->get('X-Imbo-Error-InternalCode')); $this->assertNull($this->response->headers->get('ETag')); $this->assertNull($this->response->getLastModified()); }