示例#1
0
 /**
  * Test Cache_Lite wrapper {@link epCacheCachelite}
  * 
  * Prepare Cache_Lite:
  *   Upgrade or install Cache_Lite through PEAR
  *   $ sudo pear install Cache_Lite
  *   $ sudo pear upgrade Cache_Lite
  */
 function testCachelite()
 {
     // cachelite params
     $cache_dir = dirname(__FILE__) . '/tmp/';
     $ttl = 360;
     epMkDir($cache_dir);
     // instantiate cache
     include_once EP_SRC_CACHE . '/epCacheCachelite.php';
     try {
         $this->assertTrue($cache = new epCacheCachelite($cache_dir, $ttl));
         $this->assertTrue($this->_testCache($cache));
     } catch (Exception $e) {
     }
     epRmDir($cache_dir);
 }
示例#2
0
/**
 * Make directory if not existing (with a fix to PHP5 mkdir())
 * @param string $dir
 * @param integer option
 * @return bool
 */
function epMkDir($dir, $option = 0700)
{
    // does dir exist?
    if (file_exists($dir) || is_dir($dir)) {
        return true;
    }
    // PHP 5 mkdir breaks when recursively building a
    // directory that has a '//' in the middle.
    if (!epMkDir(dirname($dir), $option)) {
        return false;
    }
    return @mkdir($dir, $option);
}
示例#3
0
 /**
  * Prepare output directory. 
  * @return false|string false if failed or string of the output dir
  * @throws epExceptionCompiler
  * @todo Backup for non-empty directory 
  */
 protected function prepareOutputDir()
 {
     // get output directory
     $compiled_dir = $this->getConfigOption('compiled_dir');
     if (!$compiled_dir) {
         throw new epExceptionCompiler('Output directory not configured. ');
         return false;
     }
     // if compiled dir is a relative path, make is absolute
     $compiled_dir = $this->getAbsolutePath($compiled_dir);
     // check if output dir exists
     if (!file_exists($compiled_dir)) {
         if (!epMkDir($compiled_dir, 0700)) {
             throw new epExceptionCompiler('Cannot create output directory [' . $compiled_dir . ']');
             return false;
         }
     }
     // validate output dir
     if (!is_dir($compiled_dir)) {
         throw new epExceptionCompiler('Output directory [' . $compiled_dir . '] is not a directory');
         return false;
     }
     // is output dir writable?
     if (!is_writable($compiled_dir)) {
         throw new epExceptionCompiler('Output directory [' . $compiled_dir . '] is not writable.');
         return false;
     }
     return $compiled_dir;
 }
示例#4
0
 /**
  * Setup output dir 
  */
 public function setUp()
 {
     epMkDir('output');
 }