()
| 313 | |
| 314 | #[tokio::test] |
| 315 | async fn rename_class_from_declaration() { |
| 316 | let backend = Backend::new_test(); |
| 317 | let uri = Url::parse("file:///test.php").unwrap(); |
| 318 | let text = concat!( |
| 319 | "<?php\n", |
| 320 | "class Widget {\n", |
| 321 | " public function render(): string { return ''; }\n", |
| 322 | "}\n", |
| 323 | "function demo(Widget $w): void {\n", |
| 324 | " $obj = new Widget();\n", |
| 325 | "}\n", |
| 326 | ); |
| 327 | |
| 328 | open_file(&backend, &uri, text).await; |
| 329 | |
| 330 | // Rename from the declaration site (line 1). |
| 331 | let edit = rename(&backend, &uri, 1, 7, "Component").await; |
| 332 | assert!(edit.is_some()); |
| 333 | |
| 334 | let file_edits = edits_for_uri(&edit.unwrap(), &uri); |
| 335 | assert!( |
| 336 | file_edits.len() >= 3, |
| 337 | "Expected at least 3 edits for Widget, got {}", |
| 338 | file_edits.len() |
| 339 | ); |
| 340 | |
| 341 | for te in &file_edits { |
| 342 | assert_eq!(te.new_text, "Component"); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | #[tokio::test] |
| 347 | async fn prepare_rename_class() { |
nothing calls this directly
no test coverage detected