19
19
20
20
use PhpOffice \PhpWord \IOFactory ;
21
21
use PhpOffice \PhpWord \PhpWord ;
22
+ use PhpOffice \PhpWord \Settings ;
22
23
23
24
/**
24
25
* Test helper class
@@ -41,9 +42,9 @@ class TestHelperDOCX
41
42
*/
42
43
public static function getDocument (PhpWord $ phpWord , $ writerName = 'Word2007 ' )
43
44
{
44
- self ::$ file = tempnam (sys_get_temp_dir (), 'PhpWord ' );
45
- if (!is_dir (sys_get_temp_dir () . '/PhpWord_Unit_Test/ ' )) {
46
- mkdir (sys_get_temp_dir () . '/PhpWord_Unit_Test/ ' );
45
+ self ::$ file = tempnam (Settings:: getTempDir (), 'PhpWord ' );
46
+ if (!is_dir (Settings:: getTempDir () . '/PhpWord_Unit_Test/ ' )) {
47
+ mkdir (Settings:: getTempDir () . '/PhpWord_Unit_Test/ ' );
47
48
}
48
49
49
50
$ xmlWriter = IOFactory::createWriter ($ phpWord , $ writerName );
@@ -52,11 +53,11 @@ public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007')
52
53
$ zip = new \ZipArchive ;
53
54
$ res = $ zip ->open (self ::$ file );
54
55
if ($ res === true ) {
55
- $ zip ->extractTo (sys_get_temp_dir () . '/PhpWord_Unit_Test/ ' );
56
+ $ zip ->extractTo (Settings:: getTempDir () . '/PhpWord_Unit_Test/ ' );
56
57
$ zip ->close ();
57
58
}
58
59
59
- return new XmlDocument (sys_get_temp_dir () . '/PhpWord_Unit_Test/ ' );
60
+ return new XmlDocument (Settings:: getTempDir () . '/PhpWord_Unit_Test/ ' );
60
61
}
61
62
62
63
/**
@@ -67,8 +68,8 @@ public static function clear()
67
68
if (file_exists (self ::$ file )) {
68
69
unlink (self ::$ file );
69
70
}
70
- if (is_dir (sys_get_temp_dir () . '/PhpWord_Unit_Test/ ' )) {
71
- self ::deleteDir (sys_get_temp_dir () . '/PhpWord_Unit_Test/ ' );
71
+ if (is_dir (Settings:: getTempDir () . '/PhpWord_Unit_Test/ ' )) {
72
+ self ::deleteDir (Settings:: getTempDir () . '/PhpWord_Unit_Test/ ' );
72
73
}
73
74
}
74
75
0 commit comments