Fix unit test error

This commit is contained in:
Ivan Lanin 2014-04-16 13:37:48 +07:00
parent 2829fd8216
commit 406534cd42
2 changed files with 37 additions and 31 deletions

View File

@ -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
*/

View 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);