/** * Instantiate the trasfer component. */ $transfer = new Dfp_Datafeed_Transfer(); /** * Create an instance of the Stream adapter. */ $adapter = new Dfp_Datafeed_Transfer_Adapter_Stream(); /** * Set the destination directory. */ $adapter->setBasePath($destinationDirectory); /** * Set the source stream scheme to file://. */ $adapter->setSchema('file'); /** * Get the path of the source file. */ $adapter->setHost(pathinfo($sourceFile, PATHINFO_DIRNAME)); /** * Add the adapter to the transfer compomnent. */ $transfer->setAdapter($adapter); /** * Get the filename from the souirce file. Set the source and destination file name. */ $filename = pathinfo($sourceFile, PATHINFO_BASENAME); /** * Transfert the file... */
public function testSendFile() { $dir = vfsStream::setup('base'); mkdir('vfs://base/src'); mkdir('vfs://base/dest'); file_put_contents('vfs://base/src/test.csv', 'testdata'); $sut = new Dfp_Datafeed_Transfer_Adapter_Stream(); $sut->setHost('base/dest'); $sut->setSchema('vfs'); $sut->setBasePath('vfs://base/src'); $sut->sendFile('test.csv'); $this->assertEquals('testdata', file_get_contents('vfs://base/dest/test.csv')); $sut->sendFile('test.csv', 'test2.csv'); $this->assertEquals('testdata', file_get_contents('vfs://base/dest/test2.csv')); }