()
| 986 | |
| 987 | #[tokio::test] |
| 988 | async fn test_parse_functions_standalone() { |
| 989 | let backend = create_test_backend(); |
| 990 | let php = concat!( |
| 991 | "<?php\n", |
| 992 | "function hello(): void {}\n", |
| 993 | "function add(int $a, int $b): int { return $a + $b; }\n", |
| 994 | ); |
| 995 | |
| 996 | let functions = backend.parse_functions(php); |
| 997 | assert_eq!(functions.len(), 2, "Should extract 2 standalone functions"); |
| 998 | |
| 999 | let hello = functions.iter().find(|f| f.name == "hello").unwrap(); |
| 1000 | assert!(hello.parameters.is_empty()); |
| 1001 | assert_eq!(hello.return_type_str().as_deref(), Some("void")); |
| 1002 | assert!(hello.namespace.is_none()); |
| 1003 | |
| 1004 | let add = functions.iter().find(|f| f.name == "add").unwrap(); |
| 1005 | assert_eq!(add.parameters.len(), 2); |
| 1006 | assert_eq!(add.parameters[0].name, "$a"); |
| 1007 | assert_eq!(add.parameters[0].type_hint_str().as_deref(), Some("int")); |
| 1008 | assert_eq!(add.parameters[1].name, "$b"); |
| 1009 | assert_eq!(add.return_type_str().as_deref(), Some("int")); |
| 1010 | assert!(add.namespace.is_none()); |
| 1011 | } |
| 1012 | |
| 1013 | #[tokio::test] |
| 1014 | async fn test_parse_functions_inside_namespace() { |
nothing calls this directly
no test coverage detected