Пример #1
0
 /**
  * Write row data to source file.
  *
  * @param array $rowData
  * @throws \Exception
  * @return $this
  */
 public function writeRow(array $rowData)
 {
     if (null === $this->_headerCols) {
         $this->setHeaderCols(array_keys($rowData));
     }
     $this->_fileHandler->writeCsv(array_merge($this->_headerCols, array_intersect_key($rowData, $this->_headerCols)), $this->_delimiter, $this->_enclosure);
     return $this;
 }
Пример #2
0
 /**
  * @expectedException \Magento\Framework\Filesystem\FilesystemException
  */
 public function testWriteCsvException()
 {
     $data = [];
     $delimiter = ',';
     $enclosure = '"';
     $this->driver->expects($this->once())->method('filePutCsv')->with($this->resource, $data, $delimiter, $enclosure)->will($this->throwException(new \Magento\Framework\Filesystem\FilesystemException()));
     $this->file->writeCsv($data, $delimiter, $enclosure);
 }
Пример #3
0
 /**
  * @expectedException \Magento\Framework\Exception\FileSystemException
  */
 public function testWriteCsvException()
 {
     $data = [];
     $delimiter = ',';
     $enclosure = '"';
     $emptyTranslation = '';
     $this->driver->expects($this->once())->method('filePutCsv')->with($this->resource, $data, $delimiter, $enclosure)->willThrowException(new FileSystemException(new Phrase($emptyTranslation)));
     $this->file->writeCsv($data, $delimiter, $enclosure);
 }