Fix unit test error
This commit is contained in:
parent
2829fd8216
commit
406534cd42
|
|
@ -48,6 +48,13 @@ abstract class AbstractWriter implements WriterInterface
|
|||
*/
|
||||
private $diskCachingDirectory = './';
|
||||
|
||||
/**
|
||||
* Temporary directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tempDir = '';
|
||||
|
||||
/**
|
||||
* Original file name
|
||||
*
|
||||
|
|
@ -62,13 +69,6 @@ abstract class AbstractWriter implements WriterInterface
|
|||
*/
|
||||
private $tempFilename;
|
||||
|
||||
/**
|
||||
* Temporary directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tempDir;
|
||||
|
||||
/**
|
||||
* Get PhpWord object
|
||||
*
|
||||
|
|
@ -88,7 +88,7 @@ abstract class AbstractWriter implements WriterInterface
|
|||
* Set PhpWord object
|
||||
*
|
||||
* @param PhpWord
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function setPhpWord(PhpWord $phpWord = null)
|
||||
{
|
||||
|
|
@ -126,7 +126,7 @@ abstract class AbstractWriter implements WriterInterface
|
|||
*
|
||||
* @param boolean $pValue
|
||||
* @param string $pDirectory
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function setUseDiskCaching($pValue = false, $pDirectory = null)
|
||||
{
|
||||
|
|
@ -153,6 +153,32 @@ abstract class AbstractWriter implements WriterInterface
|
|||
return $this->diskCachingDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get temporary directory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTempDir()
|
||||
{
|
||||
return $this->tempDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set temporary directory
|
||||
*
|
||||
* @param string $value
|
||||
* @return self
|
||||
*/
|
||||
public function setTempDir($value)
|
||||
{
|
||||
if (!is_dir($value)) {
|
||||
mkdir($value);
|
||||
}
|
||||
$this->tempDir = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get temporary file name
|
||||
*
|
||||
|
|
@ -164,7 +190,7 @@ abstract class AbstractWriter implements WriterInterface
|
|||
protected function getTempFile($filename)
|
||||
{
|
||||
// Temporary directory
|
||||
$this->setTempDir();
|
||||
$this->setTempDir(sys_get_temp_dir() . '/PHPWordWriter/');
|
||||
|
||||
// Temporary file
|
||||
$this->originalFilename = $filename;
|
||||
|
|
@ -179,26 +205,6 @@ abstract class AbstractWriter implements WriterInterface
|
|||
return $this->tempFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get temporary directory
|
||||
*/
|
||||
protected function getTempDir()
|
||||
{
|
||||
return $this->tempDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set temporary directory
|
||||
*/
|
||||
protected function setTempDir()
|
||||
{
|
||||
$tempDir = sys_get_temp_dir() . '/PHPWordMedia/';
|
||||
if (!is_dir($tempDir)) {
|
||||
mkdir($tempDir);
|
||||
}
|
||||
$this->tempDir = $tempDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup temporary file
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class HTML extends AbstractWriter implements WriterInterface
|
|||
public function save($filename = null)
|
||||
{
|
||||
if (!is_null($this->getPhpWord())) {
|
||||
$this->setTempDir();
|
||||
$this->setTempDir(sys_get_temp_dir() . '/PHPWordWriter/');
|
||||
$hFile = fopen($filename, 'w') or die("can't open file");
|
||||
fwrite($hFile, $this->writeDocument());
|
||||
fclose($hFile);
|
||||
|
|
|
|||
Loading…
Reference in New Issue