diff --git a/module/editor/test/lib/editor.unittest.class.php b/module/editor/test/lib/editor.unittest.class.php index 551c303ba2..db7576c99e 100644 --- a/module/editor/test/lib/editor.unittest.class.php +++ b/module/editor/test/lib/editor.unittest.class.php @@ -816,21 +816,56 @@ class editorTest /** * Test for get class name by path. * + * @param int $testStep * @access public * @return string */ - public function getClassNameByPathTest() + public function getClassNameByPathTest($testStep = 0) { $modulePath = $this->objectModel->app->getModulePath('', 'todo'); $extPath = $this->objectModel->app->getExtensionRoot() . 'custom' . DS; - $result = ''; - $filePath = $modulePath . 'model.php' . DS . 'create'; - $className = $this->objectModel->getClassNameByPath($filePath); - $result .= $className == 'todo' ? '1,' : '0,'; - $filePath = $extPath . 'todo' . DS . 'ext' . DS . 'control'; - $className = $this->objectModel->getClassNameByPath($filePath); - $result .= $className == 'todo' ? '1' : '0'; - return $result; + switch($testStep) + { + case 1: + // 测试module路径 + $filePath = $modulePath . 'model.php'; + $className = $this->objectModel->getClassNameByPath($filePath); + return $className == 'todo' ? '1' : '0'; + + case 2: + // 测试ext路径 + $filePath = $extPath . 'todo' . DS . 'ext' . DS . 'control'; + $className = $this->objectModel->getClassNameByPath($filePath); + return $className == 'todo' ? '1' : '0'; + + case 3: + // 测试extension路径 + $filePath = $this->objectModel->app->getExtensionRoot() . 'extension' . DS . 'custom' . DS . 'user' . DS . 'model'; + $className = $this->objectModel->getClassNameByPath($filePath); + return $className == 'user' ? '1' : '0'; + + case 4: + // 测试不包含特殊路径的情况 + $filePath = '/some/random/path/task/file.php'; + $className = $this->objectModel->getClassNameByPath($filePath); + return $className == 'file.php' ? '1' : '0'; + + case 5: + // 测试空路径 + $className = $this->objectModel->getClassNameByPath(''); + return $className == '' ? '1' : '0'; + + default: + // 原始组合测试 + $result = ''; + $filePath = $modulePath . 'model.php' . DS . 'create'; + $className = $this->objectModel->getClassNameByPath($filePath); + $result .= $className == 'todo' ? '1,' : '0,'; + $filePath = $extPath . 'todo' . DS . 'ext' . DS . 'control'; + $className = $this->objectModel->getClassNameByPath($filePath); + $result .= $className == 'todo' ? '1' : '0'; + return $result; + } } } diff --git a/module/editor/test/model/getclassnamebypath.php b/module/editor/test/model/getclassnamebypath.php old mode 100644 new mode 100755 index 85b3bd1cf3..465f71fbf2 --- a/module/editor/test/model/getclassnamebypath.php +++ b/module/editor/test/model/getclassnamebypath.php @@ -1,18 +1,29 @@ #!/usr/bin/env php > 1,1 +- 测试步骤1:module路径 @1 +- 测试步骤2:ext扩展路径 @1 +- 测试步骤3:extension路径 @1 +- 测试步骤4:不包含特殊标识路径 @1 +- 测试步骤5:空路径测试 @1 */ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/editor.unittest.class.php'; + +su('admin'); + $editor = new editorTest(); -r($editor->getClassNameByPathTest()) && p() && e('1,1'); //根据文件路径获取类名 + +r($editor->getClassNameByPathTest(1)) && p() && e('1'); // 测试步骤1:module路径 +r($editor->getClassNameByPathTest(2)) && p() && e('1'); // 测试步骤2:ext扩展路径 +r($editor->getClassNameByPathTest(3)) && p() && e('1'); // 测试步骤3:extension路径 +r($editor->getClassNameByPathTest(4)) && p() && e('1'); // 测试步骤4:不包含特殊标识路径 +r($editor->getClassNameByPathTest(5)) && p() && e('1'); // 测试步骤5:空路径测试 \ No newline at end of file