()
| 918 | |
| 919 | #[test] |
| 920 | fn single_variable_in_function() { |
| 921 | let content = r#"<?php |
| 922 | function hello() { |
| 923 | $name = "world"; |
| 924 | echo $name; |
| 925 | } |
| 926 | "#; |
| 927 | // Position cursor on `$name` in the echo statement (line 3, char 9). |
| 928 | let results = selection_ranges(content, &[Position::new(3, 9)]); |
| 929 | assert_eq!(results.len(), 1); |
| 930 | let ranges = flatten(&results[0]); |
| 931 | |
| 932 | // Should have multiple levels: at minimum variable → expression → statement → block → function → file. |
| 933 | assert!( |
| 934 | ranges.len() >= 3, |
| 935 | "Expected at least 3 selection range levels, got {}", |
| 936 | ranges.len() |
| 937 | ); |
| 938 | |
| 939 | // The innermost range should be smaller than the outermost. |
| 940 | let innermost = &ranges[0]; |
| 941 | let outermost = ranges.last().unwrap(); |
| 942 | assert!( |
| 943 | innermost.start.line >= outermost.start.line |
| 944 | || innermost.start.character >= outermost.start.character, |
| 945 | "Innermost range should be within outermost" |
| 946 | ); |
| 947 | } |
| 948 | |
| 949 | #[test] |
| 950 | fn class_method_body() { |
nothing calls this directly
no test coverage detected