From 83f4c17894577ca32f8a65d38105d61044ee7e5f Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 11 Nov 2025 02:16:02 +0800 Subject: [PATCH] + [misc] Add unit tests for productZen::getProducts4DropMenu() 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 --- module/product/test/lib/zen.class.php | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/module/product/test/lib/zen.class.php b/module/product/test/lib/zen.class.php index 2bbe111fa1..acd51f5a65 100644 --- a/module/product/test/lib/zen.class.php +++ b/module/product/test/lib/zen.class.php @@ -2052,4 +2052,39 @@ class productZenTest extends baseTest if(dao::isError()) return dao::getError(); return $result; } + + /** + * Test getProducts4DropMenu method. + * + * @param string $shadow + * @param string $module + * @param string $tab + * @param int $projectID + * @access public + * @return array|int + */ + public function getProducts4DropMenuTest(string $shadow = '0', string $module = '', string $tab = 'product', int $projectID = 0) + { + $this->instance->app->tab = $tab; + if($projectID > 0) $_SESSION['project'] = $projectID; + + $result = $this->invokeArgs('getProducts4DropMenu', array($shadow, $module)); + if(dao::isError()) return dao::getError(); + + /* Convert result to indexed array for easier testing. */ + if(is_array($result)) + { + $products = array(); + foreach($result as $product) + { + if(is_object($product)) + { + $products[] = $product; + } + } + return $products; + } + + return $result; + } }