()
| 130 | |
| 131 | #[test] |
| 132 | fn class_references_no_duplicates() { |
| 133 | let backend = create_test_backend(); |
| 134 | let uri = "file:///tmp/test_refs_class.php"; |
| 135 | let content = r#"<?php |
| 136 | |
| 137 | class Foo { |
| 138 | public function bar(): void {} |
| 139 | } |
| 140 | |
| 141 | class Baz { |
| 142 | public function test(): void { |
| 143 | $f = new Foo(); |
| 144 | $g = new Foo(); |
| 145 | } |
| 146 | } |
| 147 | "#; |
| 148 | |
| 149 | open_file(&backend, uri, content); |
| 150 | |
| 151 | // Cursor on `Foo` in the class declaration (line 2, col 6) |
| 152 | let results = backend |
| 153 | .find_references(uri, content, Position::new(2, 6), true) |
| 154 | .expect("should find references"); |
| 155 | |
| 156 | assert_no_duplicates(&results, "class_references"); |
| 157 | |
| 158 | // We expect exactly 3: the declaration + 2 usages in `new Foo()` |
| 159 | assert_eq!( |
| 160 | results.len(), |
| 161 | 3, |
| 162 | "Expected 3 references (1 declaration + 2 usages), got {}: {:#?}", |
| 163 | results.len(), |
| 164 | results |
| 165 | ); |
| 166 | } |
| 167 | |
| 168 | #[test] |
| 169 | fn class_references_without_declaration_no_duplicates() { |
nothing calls this directly
no test coverage detected