()
| 478 | |
| 479 | #[tokio::test] |
| 480 | async fn test_foreach_var_blade() { |
| 481 | let backend = create_test_backend(); |
| 482 | for (uri, text) in [ |
| 483 | ("file:///app/Models/BlogAuthor.php", BLOG_AUTHOR_FULL_PHP), |
| 484 | ( |
| 485 | "file:///app/Models/AuthorCollection.php", |
| 486 | AUTHOR_COLLECTION_PHP, |
| 487 | ), |
| 488 | ] { |
| 489 | backend |
| 490 | .did_open(DidOpenTextDocumentParams { |
| 491 | text_document: TextDocumentItem { |
| 492 | uri: Url::parse(uri).unwrap(), |
| 493 | language_id: "php".to_string(), |
| 494 | version: 1, |
| 495 | text: text.to_string(), |
| 496 | }, |
| 497 | }) |
| 498 | .await; |
| 499 | } |
| 500 | |
| 501 | let blade_uri = "file:///views/users.blade.php"; |
| 502 | let blade_text = r#"@php |
| 503 | /** |
| 504 | * @var \App\Models\AuthorCollection $users |
| 505 | */ |
| 506 | @endphp |
| 507 | |
| 508 | @foreach($users->active()->byName() as $user) |
| 509 | <p>{{ $user->name }}</p> |
| 510 | @endforeach |
| 511 | "#; |
| 512 | backend |
| 513 | .did_open(DidOpenTextDocumentParams { |
| 514 | text_document: TextDocumentItem { |
| 515 | uri: Url::parse(blade_uri).unwrap(), |
| 516 | language_id: "blade".to_string(), |
| 517 | version: 1, |
| 518 | text: blade_text.to_string(), |
| 519 | }, |
| 520 | }) |
| 521 | .await; |
| 522 | |
| 523 | // Hover on $user (line 7: " <p>{{ $user->name }}</p>") |
| 524 | let text = hover_text(&backend, blade_uri, 7, 14).await; |
| 525 | assert!( |
| 526 | text.as_ref().is_some_and(|t| t.contains("BlogAuthor")), |
| 527 | "Blade: hover on $user in foreach should show BlogAuthor, got: {:?}", |
| 528 | text |
| 529 | ); |
| 530 | } |
| 531 | |
| 532 | #[tokio::test] |
| 533 | async fn test_foreach_var_blade_with_bladestan_signature() { |
nothing calls this directly
no test coverage detected