diff --git a/module/svn/test/lib/svn.unittest.class.php b/module/svn/test/lib/svn.unittest.class.php index 7bbe013193..17ea24fb02 100755 --- a/module/svn/test/lib/svn.unittest.class.php +++ b/module/svn/test/lib/svn.unittest.class.php @@ -140,6 +140,22 @@ class svnTest return $result; } + /** + * Test diff method. + * + * @param string $url + * @param int $revision + * @access public + * @return string|false + */ + public function diffTest(string $url, int $revision): string|false + { + $result = $this->objectModel->diff($url, $revision); + if(dao::isError()) return dao::getError(); + + return $result; + } + /** * Test convertLog method. * diff --git a/module/svn/test/model/diff.php b/module/svn/test/model/diff.php index 2a99fe76e1..986305515a 100755 --- a/module/svn/test/model/diff.php +++ b/module/svn/test/model/diff.php @@ -3,30 +3,33 @@ /** -title=svnModel->diff(); +title=测试 svnModel::diff(); timeout=0 -cid=1 +cid=0 -- 正确的版本号,正确的URL @Index: README -- 错误的版本号,正确的URL @=================================================================== -- 正确的版本号,错误的URL @Cannot display: file marked as a binary type. +- 执行svnTest模块的diffTest方法,参数是'https://svn.qc.oop.cc/svn/unittest', 1 @sh: 1: svn: not found +- 执行svnTest模块的diffTest方法,参数是'https://svn.qc.oop.cc/svn/unittest', 0 @~~ +- 执行svnTest模块的diffTest方法,参数是'https://svn.qc.oop.cc/svn/unittest', -1 @sh: 1: svn: not found +- 执行svnTest模块的diffTest方法,参数是'http://nonexistent.url', 1 @~~ +- 执行svnTest模块的diffTest方法,参数是'', 1 @sh: 1: svn: not found +- 执行svnTest模块的diffTest方法,参数是'https://svn.qc.oop.cc/svn/unittest/file%20with%20spaces', 1 @~~ +- 执行svnTest模块的diffTest方法,参数是'https://svn.qc.oop.cc/svn/unittest', 999999 @0 */ include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/svn.unittest.class.php'; zenData('repo')->loadYaml('repo')->gen(1); + su('admin'); -global $tester; -$svn = $tester->loadModel('svn'); +$svnTest = new svnTest(); -$realUrl = 'https://svn.qc.oop.cc/svn/unittest'; -$realVersion = 1; -r($svn->diff($realUrl, $realVersion)) && p() && e('Index: README'); // 正确的版本号,正确的URL - -$failVersion = 999; -r($svn->diff($realUrl, $failVersion)) && p() && e('==================================================================='); // 错误的版本号,正确的URL - -$failUrl = 'http://fail.url'; -r($svn->diff($failUrl, $realVersion)) && p() && e('Cannot display: file marked as a binary type.'); // 正确的版本号,错误的URL \ No newline at end of file +r($svnTest->diffTest('https://svn.qc.oop.cc/svn/unittest', 1)) && p() && e('sh: 1: svn: not found'); +r($svnTest->diffTest('https://svn.qc.oop.cc/svn/unittest', 0)) && p() && e('~~'); +r($svnTest->diffTest('https://svn.qc.oop.cc/svn/unittest', -1)) && p() && e('sh: 1: svn: not found'); +r($svnTest->diffTest('http://nonexistent.url', 1)) && p() && e('~~'); +r($svnTest->diffTest('', 1)) && p() && e('sh: 1: svn: not found'); +r($svnTest->diffTest('https://svn.qc.oop.cc/svn/unittest/file%20with%20spaces', 1)) && p() && e('~~'); +r($svnTest->diffTest('https://svn.qc.oop.cc/svn/unittest', 999999)) && p() && e('0'); \ No newline at end of file