invokeArgs('getAssignedToOptions', [$manageLink]); if(dao::isError()) return dao::getError(); // Convert toolbar arrays to count for easier testing if(isset($result['single']['toolbar']) && is_array($result['single']['toolbar'])) { $result['single']['toolbarCount'] = count($result['single']['toolbar']); } if(isset($result['multiple']['toolbar']) && is_array($result['multiple']['toolbar'])) { $result['multiple']['toolbarCount'] = count($result['multiple']['toolbar']); // Extract first toolbar key for testing if(isset($result['multiple']['toolbar'][0]['key'])) { $result['multiple']['firstToolbarKey'] = $result['multiple']['toolbar'][0]['key']; } if(isset($result['multiple']['toolbar'][1]['key'])) { $result['multiple']['secondToolbarKey'] = $result['multiple']['toolbar'][1]['key']; } } return $result; } /** * Test getCustomFields method. * * @param object $execution * @param string $action * @access public * @return array */ public function getCustomFieldsTest(object $execution, string $action): array { $result = $this->invokeArgs('getCustomFields', [$execution, $action]); if(dao::isError()) return dao::getError(); return $result; } /** * Test getExportFields method. * * @param string $allExportFields * @param array $postData * @access public * @return array */ public function getExportFieldsTest(string $allExportFields, array $postData = array()): array { // 模拟POST数据 if(!empty($postData)) { foreach($postData as $key => $value) { $_POST[$key] = $value; } } $result = $this->invokeArgs('getExportFields', [$allExportFields]); if(dao::isError()) return dao::getError(); // 清理POST数据 foreach($postData as $key => $value) { unset($_POST[$key]); } return $result; } /** * Test processExportGroup method. * * @param int $executionID * @param array $tasks * @param string $orderBy * @access public * @return array */ public function processExportGroupTest(int $executionID, array $tasks, string $orderBy): array { try { // 使用 initReference 来获取 zen 类反射 $taskZenRef = initReference('task'); $method = $taskZenRef->getMethod('processExportGroup'); $method->setAccessible(true); // 创建 zen 实例 $taskZenInstance = $taskZenRef->newInstance(); $result = $method->invokeArgs($taskZenInstance, [$executionID, $tasks, $orderBy]); if(dao::isError()) return dao::getError(); return $result; } catch (Exception $e) { return array('error' => $e->getMessage()); } catch (Throwable $e) { return array('error' => $e->getMessage()); } } }