PHPUnit 및 vfsStream을 사용하여 move_uploaded_file 및 is_uploaded_file을 테스트 해 보았습니다. 그들은 항상 거짓을 반환합니다.vfsStream을 사용하여 move_uploaded_file 및 is_uploaded_file을 테스트하십시오.
public function testShouldUploadAZipFileAndMoveIt()
{
$_FILES = array('fieldName' => array(
'name' => 'file.zip',
'type' => 'application/zip',
'tmp_name' => 'vfs://root/file.zip',
'error' => 0,
'size' => 0,
));
vfsStream::setup();
$vfsStreamFile = vfsStream::newFile('file.zip');
vfsStreamWrapper::getRoot()
->addChild($vfsStreamFile);
$vfsStreamDirectory = vfsStream::newDirectory('/destination');
vfsStreamWrapper::getRoot()
->addChild($vfsStreamDirectory);
$fileUpload = new File_Upload();
$fileUpload->upload(
vfsStream::url('root/file.zip'),
vfsStream::url('root/destination/file.zip')
);
$this->assertFileExists(vfsStream::url('root/destination/file.zip'));
}
가능합니까? 어떻게해야합니까? PHP 코드 만 사용하여 양식없이 vfsStreamFile (또는 모든 데이터)을 게시 할 수 있습니까? 감사합니다.
어떻게 이러한 단위 테스트를 사용합니까? 감사. – user972959
실례지만. 나는 phpunit을 사용한 적이 없다. 여기에 몇 가지 것들이 있습니다 : http://stackoverflow.com/questions/3402765/how-can-i-write-tests-for-file-upload-in-php phpunit을 위해 특별히 아닙니다. –