function flush()
 {
     $files = lmbFs::find($this->getCacheDir(), 'f');
     foreach ($files as $file) {
         lmbFs::rm($file);
     }
 }
 function setUp()
 {
     $this->cache_dir = LIMB_VAR_DIR . '/fpcache/';
     lmbFs::rm($this->cache_dir);
     $this->filter2 = new MockInterceptingFilter();
     $this->user = new lmbFullPageCacheUser();
     $this->toolkit = lmbToolkit::save();
 }
Exemple #3
0
function lmb_tests_init_var_dir($value)
{
    if (file_exists($value)) {
        lmbFs::rm($value);
    }
    lmbFs::mkdir($value);
    $real = realpath($value) . '/';
    lmb_var_dir($real);
}
 function setUp()
 {
     $this->base_dir = lmb_var_dir() . '/tpl';
     $this->tpl_dir = $this->base_dir;
     $this->cache_dir = $this->base_dir . '/compiled';
     $this->tags_dir = dirname(__FILE__) . '/../../src/tags';
     $this->filters_dir = dirname(__FILE__) . '/../../src/filters';
     lmbFs::rm(lmb_var_dir());
     lmbFs::mkdir(lmb_var_dir());
     lmbFs::mkdir($this->base_dir);
     lmbFs::mkdir($this->tpl_dir);
     lmbFs::mkdir($this->cache_dir);
 }
 function testSimpleIterate()
 {
     lmbFs::rm($this->dir);
     lmbFs::mkdir($this->dir);
     $it = new lmbFsRecursiveIterator($this->dir);
     $it->rewind();
     $this->_assertDotDir($it, __LINE__);
     $it->next();
     $this->_assertDotDir($it, __LINE__);
     $it->next();
     $this->assertFalse($it->valid());
     lmbFs::rm($this->dir);
 }
 function testSafeAttribute()
 {
     lmb_env_set('LIMB_DOCUMENT_ROOT', lmb_env_get('LIMB_VAR_DIR') . '/www/');
     lmbFs::rm(lmb_env_get('LIMB_DOCUMENT_ROOT') . 'not_found.html');
     $template = '{{file:version src="not_found.html" }}';
     $page = $this->_createMacroTemplate($template, 'tpl.html');
     try {
         $page->render();
         $this->assertTrue(false);
     } catch (lmbException $e) {
         $this->assertTrue(true);
     }
     $template = '{{file:version src="not_found.html" safe="1" }}';
     $page = $this->_createMacroTemplate($template, 'tpl.html');
     $content = $this->toolkit->addVersionToUrl('not_found.html', true);
     $this->assertEqual($content, $page->render());
 }
 function testNotFoundFile()
 {
     $root = lmb_env_get('LIMB_VAR_DIR') . '/www';
     lmb_env_set('LIMB_DOCUMENT_ROOT', $root);
     lmbFs::rm($root);
     $template = '{{js_combined dir="media/"}}{{js_once src="js/main.js" }}{{/js_combined}}';
     $page = $this->_createMacroTemplate($template, 'tpl.html');
     try {
         $page->render();
         $this->assertTrue(false);
     } catch (lmbException $e) {
         $this->assertTrue(true);
     }
     lmbFs::safeWrite($root . '/js/blog.js', 'function blog() {};');
     $template = '{{js_combined dir="media"}}{{js_once src="js/main.js" safe="true" }}{{js_once src="js/blog.js" }}{{/js_combined}}';
     $page = $this->_createMacroTemplate($template, 'tpl.html');
     $page->render();
     $file = array_shift(lmbFs::ls($root . '/media/'));
     $js_content = "/* include main.js - NOT FOUND */\n\n/* include blog.js */\nfunction blog() {};";
     $this->assertEqual(file_get_contents($root . '/media/' . $file), $js_content);
 }
 function tearDown()
 {
     lmbFs::rm(LIMB_VAR_DIR . '/translations');
 }
 function tearDown()
 {
     lmbFs::rm(lmb_var_dir() . '/tmp_ini');
 }
 static function mergeInto($index1, $index2)
 {
     $index_name = basename($index2);
     $index_dir = dirname($index2);
     $old_dir = $index_dir . '-old-' . mt_rand();
     $merged_dir = lmbFs::getTmpDir() . '/merged-' . mt_rand();
     $merged = $merged_dir . '/' . $index_name;
     self::merge($index1, $index2, $merged);
     lmbFs::mv($index_dir, $old_dir);
     lmbFs::mv($merged_dir, $index_dir);
     lmbFs::rm($old_dir);
     lmbFs::cp(dirname($index1) . '/' . self::$stamp, $index_dir);
     lmbFs::rm(dirname($index1));
 }
 function setUp()
 {
     parent::setUp();
     $this->cache_dir = lmb_var_dir() . '/ini/';
     lmbFs::rm($this->cache_dir);
 }
Exemple #12
0
<?php

try {
    lmbFs::rm(lmb_var_dir());
} catch (lmbFsException $e) {
}
 function tearDown()
 {
     unset($this->logger);
     lmbFs::rm(LIMB_VAR_DIR);
     parent::tearDown();
 }
Exemple #14
0
/**
 * @desc Create folders in /www/shared for all packages
 */
function task_project_shares()
{
    lmb_require('limb/fs/src/lmbFs.class.php');
    foreach (glob(taskman_prop('PROJECT_DIR') . "/lib/limb/*/shared") as $pkg_shared) {
        $pkg = basename(dirname($pkg_shared));
        $shared_dir = taskman_prop('PROJECT_DIR') . '/www/shared/';
        if (!is_dir($shared_dir)) {
            mkdir($shared_dir, 0755, true);
        }
        $destination = $shared_dir . $pkg;
        if (is_link($destination)) {
            unlink($destination);
        } else {
            lmbFs::rm($destination);
        }
        try {
            if (function_exists('symlink')) {
                symlink($pkg_shared, $destination);
                taskman_msg("Created symlink for {$pkg} ({$destination})...\n");
            } else {
                throw new Exception();
            }
        } catch (Exception $e) {
            lmbFs::cp($pkg_shared, $destination);
            taskman_msg("Copied share for {$pkg} ({$destination})...\n");
        }
    }
}
Exemple #15
0
 function testMkdirAbsolutePath()
 {
     lmbFs::rm(LIMB_VAR_DIR . '/tmp/');
     $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/wow/hey/'));
     lmbFs::mkdir(LIMB_VAR_DIR . '/./tmp\\../tmp/wow////hey/');
     $this->assertTrue(is_dir(LIMB_VAR_DIR . '/tmp/wow/hey/'));
 }
Exemple #16
0
 protected function _clean()
 {
     lmbFs::rm($this->getProjectDir());
 }
 function tearDown()
 {
     lmbToolkit::restore();
     lmbFs::rm($this->application_configs_dir);
     lmbFs::rm($this->package_configs_dir);
 }
 function testAddVersionToUrl_Safe()
 {
     $toolkit = lmbToolkit::merge(new lmbWebAppTools());
     lmb_env_set('LIMB_DOCUMENT_ROOT', null);
     try {
         $url = $toolkit->addVersionToUrl('js/main.js', true);
         $this->assertEqual($url, 'js/main.js?00');
         $this->assertTrue(true);
     } catch (lmbException $e) {
         $this->assertTrue(false);
     }
     lmb_env_set('LIMB_DOCUMENT_ROOT', lmb_env_get('LIMB_VAR_DIR') . '/www');
     lmbFs::rm(lmb_env_get('LIMB_DOCUMENT_ROOT') . '/js/main.js');
     try {
         $url = $toolkit->addVersionToUrl('js/main.js', true);
         $this->assertEqual('js/main.js?00', $url);
         $this->assertTrue(true);
     } catch (lmbException $e) {
         $this->assertTrue(false);
     }
 }
 protected function _removeWC()
 {
     if ($this->existsWc()) {
         return lmbFs::rm($this->getWc());
     }
     return true;
 }
 function tearDown()
 {
     lmbFs::rm($this->cache_dir);
 }
 function setUp()
 {
     $this->toolkit = lmbToolkit::save();
     lmbFs::rm(LIMB_VAR_DIR . '/tpl');
     lmbFs::mkdir(LIMB_VAR_DIR . '/tpl/compiled');
 }
 function _cleanUp()
 {
     lmbFs::rm(LIMB_VAR_DIR . '/translations');
     lmbFs::rm(LIMB_VAR_DIR . '/src');
 }
Exemple #23
0
function lmb_tests_cleanup_var_dir()
{
    $var_dir = lmb_var_dir();
    lmbFs::rm($var_dir);
    echo "INFO: Var dir cleaned up in {$var_dir}\n";
}
 function tearDown()
 {
     lmbFs::rm($this->tmp_dir);
 }
Exemple #25
0
<?php

/* See details in README file */
$project_dir = realpath(dirname(__FILE__) . '/../../../../');
define("LIMB_VAR_DIR", $project_dir . '/var/i18n');
require_once $project_dir . '/setup.php';
lmb_require('limb/taskman/taskman.inc.php');
taskman_propset('PROJECT_DIR', $project_dir);
taskman_propset('TEMPLATE_DIR', $project_dir . '/template');
lmb_require('limb/i18n/cli/i18n.inc.php');
taskman_run();
lmbFs::rm(LIMB_VAR_DIR);
 function flushAll($dir = null)
 {
     return lmbFs::rm($this->storage_dir . $dir);
 }
Exemple #27
0
for ($i = 0; $i < 300; $i++) {
    $class_name = 'MyClass' . $i . 'cc';
    $object = new $class_name();
}
echo "require_once absolute: " . (microtime(true) - $mark) . PHP_EOL;
/*--------------------------------------*/
generateFiles('aa');
$mark = microtime(true);
$dir = dirname(__FILE__) . '/temp/';
for ($i = 0; $i < 300; $i++) {
    $class_name = 'MyClass' . $i . 'aa';
    lmb_require($dir . $class_name . '.class.php');
    $object = new $class_name();
}
echo "lmb_require {$i} files: " . (microtime(true) - $mark) . PHP_EOL;
lmbFs::rm(dirname(__FILE__) . '/temp/');
/*--------------------------------------*/
function generateBundle($sufffix)
{
    $bundle = "";
    for ($i = 0; $i < 300; $i++) {
        $content = getContent($i . $sufffix);
        $bundle .= $content;
    }
    file_put_contents(dirname(__FILE__) . '/temp/bundle.inc.php', '<?php ' . $bundle . ' ?>');
}
function generateFiles($sufffix)
{
    for ($i = 0; $i < 300; $i++) {
        $content = getContent($i . $sufffix);
        file_put_contents(dirname(__FILE__) . '/temp/MyClass' . $i . $sufffix . '.class.php', '<?php ' . $content . ' ?>');
 function tearDown()
 {
     lmbFs::rm(lmb_var_dir() . '/tmp_ini/');
     lmbFs::rm($this->cache_dir);
 }
 function setUp()
 {
     lmbFs::rm(LIMB_VAR_DIR . '/tags/');
     lmbFs::mkdir(LIMB_VAR_DIR . '/tags/');
 }
 function tearDown()
 {
     lmbFs::rm(LIMB_VAR_DIR);
 }