Ho provato a testare move_uploaded_file e is_uploaded_file con PHPUnit e vfsStream. Restituiscono sempre false.Test move_uploaded_file e is_uploaded_file con vfsStream
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'));
}
È possibile? Come lo faccio? Posso pubblicare un vfsStreamFile (o qualsiasi dato) senza un modulo, usando solo il codice PHP? Grazie.
Come si esegue il test dell'unità utilizzando queste funzioni? Grazie. – user972959
Nessuna idea, in realtà. Non ho mai usato phpunit. Ci sono alcune cose qui: http://stackoverflow.com/questions/3402765/how-can-i-write-tests-for-file-upload-in-php anche se non specificamente per phpunit. –