Пример #1
0
 public function testCloseClearProperties()
 {
     $handle = fopen('php://temp', 'r+');
     $stream = new Stream($handle);
     $stream->close();
     $this->assertFalse($stream->isSeekable());
     $this->assertFalse($stream->isReadable());
     $this->assertFalse($stream->isWritable());
     $this->assertNull($stream->getSize());
     $this->assertEmpty($stream->getMetadata());
 }
Пример #2
0
 public function testSuccessful()
 {
     $body = 'Foo bar!';
     $stream = fopen('php://temp', 'r+');
     fwrite($stream, $body);
     fseek($stream, 0);
     $stream = new Stream($stream);
     $upload = new UploadedFile($stream, $stream->getSize(), UPLOAD_ERR_OK, 'filename.txt', 'text/plain');
     $this->assertEquals($stream->getSize(), $upload->getSize());
     $this->assertEquals('filename.txt', $upload->getClientFilename());
     $this->assertEquals('text/plain', $upload->getClientMediaType());
     $this->cleanup[] = $to = tempnam(sys_get_temp_dir(), 'successful');
     $upload->moveTo($to);
     $this->assertFileExists($to);
     $this->assertEquals($stream->__toString(), file_get_contents($to));
 }