public function testGenerator() { $generator = new MD5(); $filename = "picture.jpg"; $new_filename = md5("picture") . ".jpg"; $this->assertEquals($generator->getFileName($filename, "image/jpg", "asdf.jpg", 0, "100", new \FileUpload\PathResolver\Simple(''), new Simple()), $new_filename); }
public function testGenerator() { $generator = new MD5(); $playground_path = __DIR__ . '/../playground'; $filename = "picture.jpg"; $new_filename = md5("picture") . ".jpg"; $server = array('CONTENT_TYPE' => 'image/jpg', 'CONTENT_LENGTH' => 30321); $file = array('tmp_name' => $playground_path . '/real-image.jpg', 'name' => 'real-image.jpg', 'size' => 30321, 'type' => 'image/jpg', 'error' => 0); $fileUpload = new FileUpload($file, $server, $generator); $fileUpload->setFileSystem(new Mock()); $fileUpload->setPathResolver(new Path($playground_path . "/uploaded")); $this->assertEquals($generator->getFileName($filename, "image/jpg", "asdf.jpg", 0, "100", $fileUpload), $new_filename); }
public function testFileIsUploadedDespiteAlreadyExistingOnTheFileSystem() { $generator = new MD5(true); //true would override files with the same name $playground_path = __DIR__ . '/../../playground'; $filename = "real-image.jpg"; $newFileName = md5("real-image") . '.jpg'; $server = array('CONTENT_TYPE' => 'image/jpg', 'CONTENT_LENGTH' => 30321); $file = array('tmp_name' => $playground_path . '/uploaded/real-image.jpg', 'name' => 'real-image.jpg', 'size' => 30321, 'type' => 'image/jpg', 'error' => 0); $fileUpload = new FileUpload($file, $server, $generator); $fileUpload->setFileSystem(new Mock()); $fileUpload->setPathResolver(new Path($playground_path)); $this->assertEquals($generator->getFileName($filename, "image/jpg", "asdf.jpg", 0, "100", $fileUpload), $newFileName); }