function testCachedDiskFiles() { $cache = new CacheFilePersister('whatever'); $cache_dir = $cache->getCacheDir(); $items = Fs :: ls($cache_dir); $this->assertEqual(sizeof($items), 0); $cache->put(1, $cache_value = 'value'); $items = Fs :: ls($cache_dir); $this->assertEqual(sizeof($items), 1); $this->assertEqual($cache->get(1), $cache_value); $cache->flushAll(); rmdir($cache_dir); }
function getClassesList() { $contents = array_merge( Fs :: ls(LIMB_DIR . '/class/core/site_objects/'), Fs :: ls(LIMB_APP_DIR . '/class/core/site_objects/') ); $classes_list = array(); foreach($contents as $file_name) { if (substr($file_name, -10, 10) == '.class.php') { $classes_list[] = substr($file_name, 0, strpos($file_name, '.')); } } return $classes_list; }
function testCpWithExclude() { $this->_createFileSystem(); $res = Fs :: cp(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow', TEST_DIR_ABSOLUTE_PATH . '/tmp/cp', false, '/hey/'); sort($res); $this->assertEqual( $res, array('test2_1', 'test2_2', 'test2_3') ); $this->assertEqual( $res, Fs :: ls(TEST_DIR_ABSOLUTE_PATH . '/tmp/cp/') ); $this->assertFalse(is_dir(TEST_DIR_ABSOLUTE_PATH . '/tmp/cp/hey')); $this->_removeFileSystem(); }
function testCachedWriteFileNoMediaFile() { $cache_manager = new ImageCacheManagerTestVersion3($this); $cache_manager->setReturnValue('isCacheable', true); $this->datasource->expectOnce('setNodeIds', array(array(1))); $this->datasource->expectOnce('setSiteObjectClassName', array('ImageObject')); $this->datasource->expectOnce('fetch'); $this->datasource->setReturnValue('fetch', array( 1 => array( 'identifier' => 'testImage', 'variations' => array( 'icon' => array( 'mediaId' => 200, 'mimeType' => 'image/jpeg' ), ) ) ) ); $c = '<p><img alt="test" src="/root?node_id=1&icon" border="0"></p>'; $cache_manager->processContent($c); $this->assertEqual(sizeof(Fs :: ls(IMAGE_CACHE_DIR)), 0); $this->_cleanUp(); }