()
| 429 | |
| 430 | #[tokio::test] |
| 431 | async fn test_foreach_var_php() { |
| 432 | let backend = create_test_backend(); |
| 433 | for (uri, text) in [ |
| 434 | ("file:///app/Models/BlogAuthor.php", BLOG_AUTHOR_FULL_PHP), |
| 435 | ( |
| 436 | "file:///app/Models/AuthorCollection.php", |
| 437 | AUTHOR_COLLECTION_PHP, |
| 438 | ), |
| 439 | ] { |
| 440 | backend |
| 441 | .did_open(DidOpenTextDocumentParams { |
| 442 | text_document: TextDocumentItem { |
| 443 | uri: Url::parse(uri).unwrap(), |
| 444 | language_id: "php".to_string(), |
| 445 | version: 1, |
| 446 | text: text.to_string(), |
| 447 | }, |
| 448 | }) |
| 449 | .await; |
| 450 | } |
| 451 | |
| 452 | let php_uri = "file:///foreach_test.php"; |
| 453 | let php_text = r#"<?php |
| 454 | /** @var \App\Models\AuthorCollection $users */ |
| 455 | foreach ($users->active()->byName() as $user) { |
| 456 | echo $user->name; |
| 457 | } |
| 458 | "#; |
| 459 | backend |
| 460 | .did_open(DidOpenTextDocumentParams { |
| 461 | text_document: TextDocumentItem { |
| 462 | uri: Url::parse(php_uri).unwrap(), |
| 463 | language_id: "php".to_string(), |
| 464 | version: 1, |
| 465 | text: php_text.to_string(), |
| 466 | }, |
| 467 | }) |
| 468 | .await; |
| 469 | |
| 470 | // Hover on $user (line 3, col 9) |
| 471 | let text = hover_text(&backend, php_uri, 3, 9).await; |
| 472 | assert!( |
| 473 | text.as_ref().is_some_and(|t| t.contains("BlogAuthor")), |
| 474 | "PHP: hover on $user in foreach should show BlogAuthor, got: {:?}", |
| 475 | text |
| 476 | ); |
| 477 | } |
| 478 | |
| 479 | #[tokio::test] |
| 480 | async fn test_foreach_var_blade() { |
nothing calls this directly
no test coverage detected