fakeBody); // Why does rewind not reset unread_bytes? //rewind($file); fseek($file, 0, SEEK_SET); $metadata = stream_get_meta_data($file); $metadata['wrapper_data'] = $this->fakeHeaders; // This is a dangerous work-around for the fact that // reset and seek don't reset the unread_bytes. $metadata['unread_bytes'] = strlen($this->fakeBody); return new \HPCloud\Transport\Response($file, $metadata); } public function testFile() { $response = $this->mockFile(); #print_r($response); $file = $response->file(); $this->assertTrue(is_resource($file)); $content = fread($file, 1024); $this->assertEquals($this->fakeBody, $content); fclose($file); } public function testContent() { $response = $this->mockFile(); $this->assertEquals($this->fakeBody, $response->content()); } public function testMetadata() { $response = $this->mockFile(); $md = $response->metadata(); $this->assertTrue(is_array($md)); $this->assertTrue(!empty($md)); } public function testHeaders() { $response = $this->mockFile(); $hdr = $response->headers(); $this->assertTrue(!empty($hdr)); $headers = $response->headers(); $this->assertEquals('close', $headers['Connection']); } public function testHeader() { $response = $this->mockFile(); $this->assertEquals('close', $response->header('Connection')); $this->assertNull($response->header('FAKE')); $this->assertEquals('YAY', $response->header('FAKE', 'YAY')); } public function testStatus() { $response = $this->mockFile(); $this->assertEquals(200, $response->status()); } public function testStatusMessage() { $response = $this->mockFile(); $this->assertEquals('OK', $response->statusMessage()); } public function testProtocol() { $response = $this->mockFile(); $this->assertEquals('HTTP/1.1', $response->protocol()); } }