1, 'password' => 'test123456', 'username' => 'test_user' ]; /** * 灾害去除测试配置 */ public const DISASTER_REMOVAL_TEST = [ // 除虫测试配置 'pesticide' => [ 'land_id' => 1, // 测试土地ID(需要有虫害的土地) 'item_id' => 101, // 除虫剂物品ID 'disaster_type' => 2, // 虫害类型 'expected_success_rate' => 80 // 预期成功率 ], // 除草测试配置 'weedicide' => [ 'land_id' => 2, // 测试土地ID(需要有杂草的土地) 'item_id' => 102, // 除草剂物品ID 'disaster_type' => 3, // 杂草类型 'expected_success_rate' => 75 // 预期成功率 ], // 浇水测试配置 'watering' => [ 'land_id' => 3, // 测试土地ID(需要有干旱的土地) 'item_id' => 103, // 浇水道具物品ID 'disaster_type' => 1, // 干旱类型 'expected_success_rate' => 90 // 预期成功率 ] ]; /** * 测试物品配置 */ public const TEST_ITEMS = [ // 除虫剂 'pesticide' => [ 'item_id' => 101, 'name' => '高效除虫剂', 'numeric_attributes' => [ 'fram_pesticide_rate' => 80 // 80%成功率 ] ], // 除草剂 'weedicide' => [ 'item_id' => 102, 'name' => '强力除草剂', 'numeric_attributes' => [ 'fram_weedicide_rate' => 75 // 75%成功率 ] ], // 浇水道具 'watering_tool' => [ 'item_id' => 103, 'name' => '自动洒水器', 'numeric_attributes' => [ 'fram_drought_rate' => 90 // 90%成功率 ] ], // 无效物品(用于测试失败情况) 'invalid_item' => [ 'item_id' => 999, 'name' => '无效物品', 'numeric_attributes' => [] ] ]; /** * 测试土地配置 */ public const TEST_LANDS = [ // 有虫害的土地 'pest_land' => [ 'land_id' => 1, 'user_id' => 1, 'disaster_type' => 2, // 虫害 'crop_id' => 1, 'growth_stage' => 2 ], // 有杂草的土地 'weed_land' => [ 'land_id' => 2, 'user_id' => 1, 'disaster_type' => 3, // 杂草 'crop_id' => 2, 'growth_stage' => 3 ], // 有干旱的土地 'drought_land' => [ 'land_id' => 3, 'user_id' => 1, 'disaster_type' => 1, // 干旱 'crop_id' => 3, 'growth_stage' => 1 ], // 无灾害的土地(用于测试失败情况) 'normal_land' => [ 'land_id' => 4, 'user_id' => 1, 'disaster_type' => 0, // 无灾害 'crop_id' => 4, 'growth_stage' => 2 ], // 其他用户的土地(用于测试权限) 'other_user_land' => [ 'land_id' => 5, 'user_id' => 2, // 不同用户 'disaster_type' => 2, 'crop_id' => 5, 'growth_stage' => 1 ] ]; /** * 测试场景配置 */ public const TEST_SCENARIOS = [ // 成功场景 'success_scenarios' => [ 'pesticide_success' => [ 'description' => '除虫成功测试', 'user_id' => 1, 'land_id' => 1, 'item_id' => 101, 'expected_result' => 'success' ], 'weedicide_success' => [ 'description' => '除草成功测试', 'user_id' => 1, 'land_id' => 2, 'item_id' => 102, 'expected_result' => 'success' ], 'watering_success' => [ 'description' => '浇水成功测试', 'user_id' => 1, 'land_id' => 3, 'item_id' => 103, 'expected_result' => 'success' ] ], // 失败场景 'failure_scenarios' => [ 'invalid_item' => [ 'description' => '使用无效物品测试', 'user_id' => 1, 'land_id' => 1, 'item_id' => 999, 'expected_error' => '不是除虫物品' ], 'no_permission' => [ 'description' => '无权限访问土地测试', 'user_id' => 1, 'land_id' => 5, // 其他用户的土地 'item_id' => 101, 'expected_error' => '土地不存在或不属于当前用户' ], 'no_disaster' => [ 'description' => '土地无对应灾害测试', 'user_id' => 1, 'land_id' => 4, // 无灾害的土地 'item_id' => 101, 'expected_error' => '灾害清理失败' ] ] ]; /** * 获取测试用户ID */ public static function getTestUserId(): int { return self::TEST_USER['user_id']; } /** * 获取测试用户密码 */ public static function getTestUserPassword(): string { return self::TEST_USER['password']; } /** * 获取除虫测试配置 */ public static function getPesticideTestConfig(): array { return self::DISASTER_REMOVAL_TEST['pesticide']; } /** * 获取除草测试配置 */ public static function getWeedicideTestConfig(): array { return self::DISASTER_REMOVAL_TEST['weedicide']; } /** * 获取浇水测试配置 */ public static function getWateringTestConfig(): array { return self::DISASTER_REMOVAL_TEST['watering']; } /** * 获取测试物品配置 */ public static function getTestItem(string $type): array { return self::TEST_ITEMS[$type] ?? []; } /** * 获取测试土地配置 */ public static function getTestLand(string $type): array { return self::TEST_LANDS[$type] ?? []; } /** * 获取测试场景配置 */ public static function getTestScenario(string $category, string $scenario): array { return self::TEST_SCENARIOS[$category][$scenario] ?? []; } }