From fa584fbd37cecdb691c972e76b42f2fc02a968d4 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 8 Sep 2025 11:33:48 +0800 Subject: [PATCH] + [misc] Add unit tests for extensionModel::cleanModelCache() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../test/lib/extension.unittest.class.php | 18 ++++++++++ .../extension/test/model/cleanmodelcache.php | 33 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 module/extension/test/model/cleanmodelcache.php diff --git a/module/extension/test/lib/extension.unittest.class.php b/module/extension/test/lib/extension.unittest.class.php index c418a8f41a..f04d4f1959 100644 --- a/module/extension/test/lib/extension.unittest.class.php +++ b/module/extension/test/lib/extension.unittest.class.php @@ -78,4 +78,22 @@ class extensionTest return $result; } + + /** + * Test cleanModelCache method. + * + * @access public + * @return bool + */ + public function cleanModelCacheTest() + { + $reflection = new ReflectionClass($this->objectModel); + $method = $reflection->getMethod('cleanModelCache'); + $method->setAccessible(true); + + $result = $method->invoke($this->objectModel); + if(dao::isError()) return dao::getError(); + + return $result; + } } \ No newline at end of file diff --git a/module/extension/test/model/cleanmodelcache.php b/module/extension/test/model/cleanmodelcache.php new file mode 100755 index 0000000000..7dcfee721c --- /dev/null +++ b/module/extension/test/model/cleanmodelcache.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +cleanModelCacheTest()) && p() && e('1'); // 步骤1:正常清理缓存 +r($extensionTest->cleanModelCacheTest()) && p() && e('1'); // 步骤2:重复清理缓存 +r($extensionTest->cleanModelCacheTest()) && p() && e('1'); // 步骤3:无缓存文件时清理 +r($extensionTest->cleanModelCacheTest()) && p() && e('1'); // 步骤4:继续清理确认稳定性 +r($extensionTest->cleanModelCacheTest()) && p() && e('1'); // 步骤5:最终验证清理功能 \ No newline at end of file