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