public function testRetrieveFile() { $mockAdapter = $this->getMock('Dfp_Datafeed_Transfer_Adapter_Interface'); $mockAdapter->expects($this->once())->method('retrieveFile')->with($this->equalTo('test.txt'), $this->equalTo('test.csv')); $sut = new Dfp_Datafeed_Transfer(); $passed = false; try { $sut->retrieveFile('test.txt', 'test.csv'); } catch (Dfp_Datafeed_Transfer_Exception $e) { $passed = true; } $this->assertTrue($passed, 'Failed to throw exception when adapter is missing'); $sut->setAdapter($mockAdapter); $sut->retrieveFile('test.txt', 'test.csv'); }
$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... */ //settype($filename1, 'string'); $transfer->retrieveFile($filename, $filename);