public function testcritical() { $exception = new \Exception('error message'); $expected = "%aEXCEPTION%a'Exception'%a'error message'%a"; $this->stream->expects($this->once())->method('write')->with($this->matches($expected)); $this->object->critical($exception); }
/** * Check if process is locked by another user * * @param bool $needUnlock * @return bool|null */ public function isProcessLocked($needUnlock = true) { if (!$this->_streamHandler) { return null; } if ($this->_processLocked !== null) { return $this->_processLocked; } else { try { $this->_streamHandler->lock(LOCK_EX | LOCK_NB); if ($needUnlock) { $this->_streamHandler->unlock(); $this->_streamLocked = false; } else { $this->_streamLocked = true; } return false; } catch (FilesystemException $e) { return true; } } }
/** * Write item data to csv export file * * @param \Magento\Framework\Object $item * @param \Magento\Framework\Filesystem\File\WriteInterface $stream * @return void */ protected function _exportCsvItem(\Magento\Framework\Object $item, \Magento\Framework\Filesystem\File\WriteInterface $stream) { $row = []; foreach ($this->getColumns() as $column) { if (!$column->getIsSystem()) { $row[] = $column->getRowFieldExport($item); } } $stream->writeCsv($row); }
/** * Closing file stream * * @param \Magento\Framework\Filesystem\File\WriteInterface $stream * @return void */ protected function closeStream($stream) { if ($stream) { $stream->close(); } }
/** * Write Converted XML Data to Temporary File * * @param WriteInterface $stream * @param string $sheetName * @return void */ public function write(WriteInterface $stream, $sheetName = '') { $stream->write($this->_getXmlHeader($sheetName)); foreach ($this->_iterator as $dataRow) { $stream->write($this->_getXmlRow($dataRow, true)); } $stream->write($this->_getXmlFooter()); }