1<?php 2 3/** 4 * @author Markus Tacker <tacker@php.net> 5 */ 6 7/** 8 * @const String Temp dir for cache files 9 */ 10define('TEST_TMP_DIR_DEFAULT', __DIR__ . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR); 11 12/** 13 * Returns a directory to use for temp files. 14 * 15 * The dir is now hard coded to a local dir to make the tests runnable 16 * under jenkins where there is no write access to the system temp dir. 17 * 18 * The reason for this solution is, that with phpt files a given 19 * --bootstrap file is ignored. 20 * 21 * @author Markus Tacker <tacker@php.net>* 22 * @static 23 * @access public 24 * @return string The system tmp directory 25 */ 26function tmpDir() 27{ 28 if (defined('TEST_TMP_DIR')) return TEST_TMP_DIR; 29 return TEST_TMP_DIR_DEFAULT; 30} 31 32// Create directory if not exists 33if (!is_dir(tmpDir())) mkdir(tmpDir()); 34 35// Clean up afterwards 36register_shutdown_function(function() 37{ 38 exec('rm -rf ' . tmpDir()); 39}); 40 41