Ejemplo n.º 1
0
//file_put_contents($sourceFile, 'Some-data');
//$sourceFile = 'file://' . $sourceFile;
echo $sourceFile . PHP_EOL;
// Get a testing destination path.
$destinationDirectory = $sysTmpDir . '/dfp-dst';
if (!file_exists($destinationDirectory)) {
    mkdir($destinationDirectory, 0777, true);
}
/**
 * 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.
 */
Ejemplo n.º 2
0
 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'));
 }