()
| 533 | |
| 534 | #[test] |
| 535 | fn this_references_no_duplicates() { |
| 536 | let backend = create_test_backend(); |
| 537 | let uri = "file:///tmp/test_refs_this.php"; |
| 538 | let content = r#"<?php |
| 539 | |
| 540 | class Foo { |
| 541 | public string $name = ''; |
| 542 | |
| 543 | public function test(): void { |
| 544 | $this->name = 'hello'; |
| 545 | echo $this->name; |
| 546 | $this->doSomething(); |
| 547 | } |
| 548 | |
| 549 | public function doSomething(): void {} |
| 550 | } |
| 551 | "#; |
| 552 | |
| 553 | open_file(&backend, uri, content); |
| 554 | |
| 555 | // Cursor on `$this` (line 6, col 9) |
| 556 | let results = backend |
| 557 | .find_references(uri, content, Position::new(6, 9), true) |
| 558 | .expect("should find references"); |
| 559 | |
| 560 | assert_no_duplicates(&results, "this_references"); |
| 561 | |
| 562 | // 3 usages of $this in the method |
| 563 | assert_eq!( |
| 564 | results.len(), |
| 565 | 3, |
| 566 | "Expected 3 references ($this usages), got {}: {:#?}", |
| 567 | results.len(), |
| 568 | results |
| 569 | ); |
| 570 | } |
| 571 | |
| 572 | // ─── Cross-file references ────────────────────────────────────────────────── |
| 573 |
nothing calls this directly
no test coverage detected