FileUpload\FileNameGenerator\CustomTest::testClosureGenerator PHP Méthode

testClosureGenerator() public méthode

    public function testClosureGenerator()
    {
        $customName = function ($source_name, $type, $tmp_name, $index, $content_range, FileUpload $upload) {
            return $index . $type . $source_name . $tmp_name;
        };
        $generator = new Custom($customName);
        $playground_path = __DIR__ . '/../playground';
        $filename = "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 Simple($playground_path . "/uploaded"));
        $new_filename = $customName($filename, "image/jpg", "asdf.jpg", 0, "100", $fileUpload);
        $this->assertEquals($generator->getFileName($filename, "image/jpg", "asdf.jpg", 0, "100", $fileUpload), $new_filename);
    }