/**
  * Recursively adds all the files in a directory to the test suite.
  *
  * @param string $directory The directory subtree to add tests from.
  * @return void
  */
 public function addTestDirectoryRecursive($directory = '.')
 {
     $Folder = new Folder($directory);
     $files = $Folder->tree(null, true, 'files');
     foreach ($files as $file) {
         $this->addTestFile($file);
     }
 }
예제 #2
0
 /**
  * Recursively adds all the files in a directory to the test suite.
  *
  * @param string $directory The directory subtree to add tests from.
  *
  * @return void
  */
 public function addTestDirectoryRecursive($directory = '.')
 {
     $Folder = new Folder($directory);
     $files = $Folder->tree(NULL, TRUE, 'files');
     foreach ($files as $file) {
         if (substr($file, -4) === '.php') {
             $this->addTestFile($file);
         }
     }
 }
예제 #3
0
 /**
  * Recursively adds all the files in a directory to the test suite.
  *
  * @param string $directory The directory subtree to add tests from.
  * @return void
  */
 public function addTestDirectoryRecursive($directory = '.')
 {
     $Folder = new Folder($directory);
     $files = $Folder->tree(null, false, 'files');
     foreach ($files as $file) {
         if (strpos($file, DS . '.') !== false) {
             continue;
         }
         $this->addTestFile($file);
     }
 }
예제 #4
0
 /**
  * All test suite
  *
  * @return CakeTestSuite
  */
 public static function suite()
 {
     $plugin = preg_replace('/^All([\\w]+)Test$/', '$1', __CLASS__);
     $suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
     $directory = CakePlugin::path($plugin) . 'Test' . DS . 'Case';
     $Folder = new Folder($directory);
     $exceptions = array('CommentsModelTestBase.php');
     $files = $Folder->tree(null, $exceptions, 'files');
     foreach ($files as $file) {
         if (substr($file, -4) === '.php') {
             $suite->addTestFile($file);
         }
     }
     return $suite;
 }
예제 #5
0
 /**
  * All test suite
  *
  * @return CakeTestSuite
  */
 public static function suite()
 {
     $plugin = preg_replace('/^All([\\w]+)Test$/', '$1', __CLASS__);
     $suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
     $directory = CakePlugin::path($plugin) . 'Test' . DS . 'Case';
     $Folder = new Folder($directory);
     $exceptions = array('FaqsControllerTestBase.php', 'FaqsModelTestBase.php', 'FaqQuestionOrderTestBase.php', 'FaqQuestionTestBase.php', 'FaqSettingTestBase.php', 'FaqTestBase.php', 'BlockRolePermissionsControllerEditTest.php', 'BlocksControllerAddTest.php', 'BlocksControllerEditTest.php', 'BlocksControllerIndexTest.php', 'FaqQuestionOrdersControllerEditTest.php', 'FaqQuestionsControllerAddTest.php', 'FaqQuestionsControllerDeleteTest.php', 'FaqQuestionsControllerEditTest.php', 'FaqQuestionsControllerIndexTest.php', 'FaqQuestionsControllerViewTest.php', 'FaqsControlleIndexrTest.php', 'FaqsControllerTestBase.php', 'FaqDeleteFaqTest.php', 'FaqGetFaqTest.php', 'FaqQuestionDeleteFaqQuestionTest.php', 'FaqQuestionGetFaqQuestionsTest.php', 'FaqQuestionGetFaqQuestionTest.php', 'FaqQuestionOrderBeforeDeleteTest.php', 'FaqQuestionOrderGetMaxWeightTest.php', 'FaqQuestionOrderSaveFaqQuestionOrdersTest.php', 'FaqQuestionOrderTestBase.php', 'FaqQuestionOrderValidateFaqQuestionOrderTest.php', 'FaqQuestionSaveFaqQuestionTest.php', 'FaqQuestionTestBase.php', 'FaqQuestionValidateFaqQuestionTest.php', 'FaqSaveFaqTest.php', 'FaqSettingGetFaqSettingTest.php', 'FaqSettingSaveFaqSettingTest.php', 'FaqSettingTestBase.php', 'FaqSettingValidateFaqSettingTest.php', 'FaqsModelTestBase.php', 'FaqTestBase.php', 'FaqValidateFaqTest.php');
     $files = $Folder->tree(null, $exceptions, 'files');
     foreach ($files as $file) {
         if (substr($file, -4) === '.php') {
             $suite->addTestFile($file);
         }
     }
     return $suite;
 }
예제 #6
0
 /**
  * All test suite
  *
  * @return CakeTestSuite
  */
 public static function suite()
 {
     $plugin = preg_replace('/^All([\\w]+)Test$/', '$1', __CLASS__);
     $suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
     $directory = CakePlugin::path($plugin) . 'Test' . DS . 'Case';
     $Folder = new Folder($directory);
     $exceptions = array('BlocksControllerTestBase.php', 'IframesControllerTestBase.php', 'IframesModelTestBase.php', 'BlocksControllerAddTest.php', 'BlocksControllerDeleteTest.php', 'BlocksControllerEditTest.php', 'BlocksControllerIndexTest.php', 'BlocksControllerTestBase.php', 'IframesControllerTestBase.php', 'IframesControllerViewTest.php', 'IframeDeleteTest.php', 'IframeGetTest.php', 'IframeSaveTest.php', 'IframesModelTestBase.php', 'IframeValidateTest.php');
     $files = $Folder->tree(null, $exceptions, 'files');
     foreach ($files as $file) {
         if (substr($file, -4) === '.php') {
             $suite->addTestFile($file);
         }
     }
     return $suite;
 }
예제 #7
0
 /**
  * All test suite
  *
  * @return CakeTestSuite
  */
 public static function suite()
 {
     $plugin = preg_replace('/^All([\\w]+)Test$/', '$1', __CLASS__);
     $suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
     $directory = CakePlugin::path($plugin) . 'Test' . DS . 'Case';
     $Folder = new Folder($directory);
     $exceptions = array('RssReadersControllerTestBase.php', 'RssReadersModelTestBase.php', 'RssReaderFrameSettingSaveRssReaderFrameSettingTest.php', 'RssReaderFrameSettingValidateRssReaderFrameSettingTest.php', 'RssReaderGetRssReaderTest.php', 'RssReaderItemGetRssReaderItemsTest.php', 'RssReaderItemSerializeXmlToArrayTest.php', 'RssReaderItemUpdateRssReaderItemsTest.php', 'RssReaderItemValidateRssReaderItemsTest.php', 'RssReaderSaveRssReaderTest.php', 'RssReadersModelTestBase.php', 'RssReaderValidateRssReaderTest.php', 'RssReaderFrameSettingsControllerEditTest.php', 'RssReadersControllerEditTest.php', 'RssReadersControllerGetTest.php', 'RssReadersControllerTestBase.php', 'RssReadersControllerViewTest.php');
     $files = $Folder->tree(null, $exceptions, 'files');
     foreach ($files as $file) {
         if (substr($file, -4) === '.php') {
             $suite->addTestFile($file);
         }
     }
     return $suite;
 }
 function admin_ckselect($dir = '')
 {
     if (!empty($dir)) {
         $args = func_get_args();
         foreach ($args as $n => $arg) {
             $args[$n] = $this->_urldecode($arg);
         }
         $dir = implode('/', $args);
     }
     $_root_dir = new Folder($this->docs_path . DS . $dir);
     $resources = $_root_dir->read(true, true);
     $dir_tree = $_root_dir->tree($this->docs_path, true, 'dir');
     foreach ($dir_tree as $n => $node) {
         $dir_tree[$n] = substr($node, strlen($this->docs_path));
     }
     $getstring = '?CKEditor=' . $this->params['url']['CKEditor'] . '&CKEditorFuncNum=' . $this->params['url']['CKEditorFuncNum'] . '&langCode=' . $this->params['url']['langCode'];
     $ckeditorfuncnum = $this->params['url']['CKEditorFuncNum'];
     $this->set('docs_dir', $this->docs_dir);
     $this->set('dir', $dir);
     $this->set('dir_tree', $dir_tree);
     $this->set(compact('resources', 'getstring', 'ckeditorfuncnum'));
     $this->pageTitle = __('Select a file', true);
     $this->layout = 'ckselect';
 }
예제 #9
0
 private function __advancedFolderFind($conditions)
 {
     if (empty($this->fileList[0])) {
         $this->return = array();
         return true;
     }
     $i = 0;
     foreach ($this->fileList[0] as $folder) {
         if (in_array($folder, $this->ignore)) {
             continue;
         }
         if ($this->recursive > -2) {
             $Folder = new Folder($this->path . DS . $folder);
             $this->return[$i]['Folder']['path'] = $Folder->path;
             $this->return[$i]['Folder']['name'] = basename($this->return[$i]['Folder']['path']);
             $this->return[$i]['Folder']['parent'] = dirname($this->return[$i]['Folder']['path']);
             $this->return[$i]['Folder']['relative'] = $this->__relativePath($this->return[$i]['Folder']['path']);
             $stat = stat($this->return[$i]['Folder']['path']);
             $this->__fileStatus($i, $stat);
             if ($this->recursive > -1) {
                 $this->return[$i]['Folder']['accessed'] = date('Y-m-d H:i:s', $stat['atime']);
                 $this->return[$i]['Folder']['modified'] = date('Y-m-d H:i:s', $stat['mtime']);
                 $this->return[$i]['Folder']['created'] = date('Y-m-d H:i:s', $stat['ctime']);
                 if ($this->recursive > 0) {
                     $this->return[$i]['Folder']['size'] = $Folder->dirsize();
                     $this->return[$i]['Folder']['absolute'] = $Folder->isAbsolute($this->return[$i]['Folder']['path']);
                     $children = $Folder->tree($this->return[$i]['Folder']['path']);
                     $this->return[$i]['Folder']['sub_folders'] = count($children[0]) - 1;
                     $this->return[$i]['Folder']['sub_files'] = count($children[1]);
                     if ($this->recursive > 1) {
                         $this->return[$i]['Folder']['realpath'] = $Folder->realpath($this->return[$i]['Folder']['path']);
                         $this->return[$i]['Folder']['windows'] = $Folder->isWindowsPath($this->return[$i]['Folder']['path']);
                         $this->return[$i]['Folder']['Children'] = $children;
                         $this->return[$i]['Folder']['Extended'] = $stat;
                         $i++;
                         continue;
                     }
                     $i++;
                 }
                 $i++;
             }
             $i++;
         }
         $i++;
     }
     return true;
 }
예제 #10
0
 /**
  * testFolderTreeWithHiddenFiles method
  *
  * @return void
  */
 public function testFolderTreeWithHiddenFiles()
 {
     $this->skipIf(!is_writable(TMP), 'Can\'t test Folder::tree with hidden files unless the tmp folder is writable.');
     $Folder = new Folder(TMP . 'folder_tree_hidden', true, 0777);
     mkdir($Folder->path . DS . '.svn', 0777, true);
     touch($Folder->path . DS . '.svn' . DS . 'InHiddenFolder.php');
     mkdir($Folder->path . DS . '.svn' . DS . 'inhiddenfolder');
     touch($Folder->path . DS . '.svn' . DS . 'inhiddenfolder' . DS . 'NestedInHiddenFolder.php');
     touch($Folder->path . DS . 'not_hidden.txt');
     touch($Folder->path . DS . '.hidden.txt');
     mkdir($Folder->path . DS . 'visible_folder' . DS . '.git', 0777, true);
     $expected = array(array($Folder->path, $Folder->path . DS . 'visible_folder'), array($Folder->path . DS . 'not_hidden.txt'));
     $result = $Folder->tree(null, true);
     $this->assertEquals($expected, $result);
     $result = $Folder->tree(null, array('.'));
     $this->assertEquals($expected, $result);
     $expected = array(array($Folder->path, $Folder->path . DS . 'visible_folder', $Folder->path . DS . 'visible_folder' . DS . '.git', $Folder->path . DS . '.svn', $Folder->path . DS . '.svn' . DS . 'inhiddenfolder'), array($Folder->path . DS . 'not_hidden.txt', $Folder->path . DS . '.hidden.txt', $Folder->path . DS . '.svn' . DS . 'inhiddenfolder' . DS . 'NestedInHiddenFolder.php', $Folder->path . DS . '.svn' . DS . 'InHiddenFolder.php'));
     $result = $Folder->tree(null, false);
     sort($result[0]);
     sort($expected[0]);
     sort($result[1]);
     sort($expected[1]);
     $this->assertEquals($expected, $result);
     $Folder->delete();
 }
 /**
  * Recursively checks if the given directory (and its content) can be deleted.
  *
  * This method automatically registers an error message if validation fails.
  *
  * @param string $path Directory to check
  * @return bool
  */
 protected function _canBeDeleted($path)
 {
     if (!file_exists($path) || !is_dir($path)) {
         $this->err(__d('installer', "Plugin's directory was not found: ", $path));
         return false;
     }
     $folder = new Folder($path);
     $content = $folder->tree();
     $notWritable = [];
     foreach ($content as $foldersOrFiles) {
         foreach ($foldersOrFiles as $element) {
             if (!is_writable($element)) {
                 $notWritable[] = $element;
             }
         }
     }
     if (!empty($notWritable)) {
         $this->err(__d('installer', "Some plugin's files or directories cannot be removed from your server:"));
         foreach ($notWritable as $path) {
             $this->err(__d('installer', "  -{0}", $path));
         }
         return false;
     }
     return true;
 }
예제 #12
0
 /**
  * testFolderTree method
  *
  * @access public
  * @return void
  */
 function testFolderTree()
 {
     $Folder = new Folder();
     $expected = array(array(TEST_CAKE_CORE_INCLUDE_PATH . 'config', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding'), array(TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'paths.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0080_00ff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0100_017f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0180_024F.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0250_02af.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0370_03ff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0400_04ff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0500_052f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0530_058f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '1e00_1eff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '1f00_1fff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2100_214f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2150_218f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2460_24ff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c00_2c5f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c60_2c7f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c80_2cff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . 'ff00_ffef.php'));
     $result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false);
     $this->assertIdentical(array_diff($expected[0], $result[0]), array());
     $this->assertIdentical(array_diff($result[0], $expected[0]), array());
     $result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false, 'dir');
     $this->assertIdentical(array_diff($expected[0], $result), array());
     $this->assertIdentical(array_diff($result, $expected[0]), array());
     $result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false, 'files');
     $this->assertIdentical(array_diff($expected[1], $result), array());
     $this->assertIdentical(array_diff($result, $expected[1]), array());
 }
예제 #13
0
 /**
  * Locates the $file in $__paths, searches recursively.
  *
  * @param string $file full file name
  * @param boolean $recursive search $__paths recursively
  * @return mixed boolean on fail, $file directory path on success
  * @access private
  */
 private static function __find($file, $recursive = true)
 {
     if (empty(self::$search)) {
         return null;
     } elseif (is_string(self::$search)) {
         self::$search = array(self::$search);
     }
     if (empty(self::$__paths)) {
         self::$__paths = Cache::read('dir_map', '_cake_core_');
     }
     foreach (self::$search as $path) {
         $path = rtrim($path, DS);
         if ($path === rtrim(APP, DS)) {
             $recursive = false;
         }
         if ($recursive === false) {
             if (self::__load($path . DS . $file)) {
                 return $path . DS;
             }
             continue;
         }
         if (!isset(self::$__paths[$path])) {
             if (!class_exists('Folder')) {
                 require LIBS . 'folder.php';
             }
             $Folder = new Folder();
             $directories = $Folder->tree($path, array('.svn', 'tests', 'templates'), 'dir');
             sort($directories);
             self::$__paths[$path] = $directories;
         }
         foreach (self::$__paths[$path] as $directory) {
             if (self::__load($directory . DS . $file)) {
                 return $directory . DS;
             }
         }
     }
     return null;
 }
예제 #14
0
 /**
  * Recursively add all directories under `$path/Test/Case`.
  *
  * @param CakeTestSuite $Suite CakeTestSuite instance.
  * @param string $path Root path where to find 'Test/Case'.
  * @return CakeTestSuite Modified CakeTestSuite instance.
  */
 protected static function _addTestDirectoryRecursive(CakeTestSuite $Suite, $path)
 {
     $Folder = new Folder($path . 'Test' . DS . 'Case');
     $dirs = $Folder->tree(null, true, 'dir');
     array_shift($dirs);
     foreach ($dirs as $dir) {
         $Suite->addTestDirectoryRecursive($dir);
     }
     return $Suite;
 }
예제 #15
0
파일: FolderTest.php 프로젝트: Nervie/Beta
 /**
  * testFolderTree method
  *
  * @access public
  * @return void
  */
 public function testFolderTree()
 {
     $Folder = new Folder();
     $expected = array(array(CAKE . 'Config', CAKE . 'Config' . DS . 'unicode', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding'), array(CAKE . 'Config' . DS . 'config.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0080_00ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0100_017f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0180_024F.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0250_02af.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0370_03ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0400_04ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0500_052f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0530_058f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '1e00_1eff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '1f00_1fff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2100_214f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2150_218f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2460_24ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c00_2c5f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c60_2c7f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c80_2cff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . 'ff00_ffef.php'));
     $result = $Folder->tree(CAKE . 'Config', false);
     $this->assertSame(array_diff($expected[0], $result[0]), array());
     $this->assertSame(array_diff($result[0], $expected[0]), array());
     $result = $Folder->tree(CAKE . 'Config', false, 'dir');
     $this->assertSame(array_diff($expected[0], $result), array());
     $this->assertSame(array_diff($expected[0], $result), array());
     $result = $Folder->tree(CAKE . 'Config', false, 'files');
     $this->assertSame(array_diff($expected[1], $result), array());
     $this->assertSame(array_diff($expected[1], $result), array());
 }
예제 #16
0
 /**
  * Locates the $file in $__paths, searches recursively.
  *
  * @param string $file full file name
  * @param boolean $recursive search $__paths recursively
  * @return mixed boolean on fail, $file directory path on success
  * @access private
  */
 function __find($file, $recursive = true)
 {
     if (empty($this->search)) {
         return null;
     } elseif (is_string($this->search)) {
         $this->search = array($this->search);
     }
     if (empty($this->__paths)) {
         $this->__paths = S2Cache::read('dir_map', '_s2framework_core_');
     }
     foreach ($this->search as $path) {
         $path = rtrim($path, DS);
         if ($path === rtrim(APP, DS)) {
             $recursive = false;
         }
         if ($recursive === false) {
             if ($this->__load($path . DS . $file)) {
                 return $path . DS;
             }
             continue;
         }
         if (!isset($this->__paths[$path])) {
             if (!class_exists('Folder')) {
                 require LIBS . 'folder.php';
             }
             $Folder = new Folder();
             $directories = $Folder->tree($path, false, 'dir');
             $this->__paths[$path] = $directories;
         }
         foreach ($this->__paths[$path] as $directory) {
             if ($this->__load($directory . DS . $file)) {
                 return $directory . DS;
             }
         }
     }
     return null;
 }