()
| 138 | |
| 139 | #[test] |
| 140 | fn require_once_dirname_dir() { |
| 141 | let dir = tempfile::tempdir().unwrap(); |
| 142 | let sub_dir = dir.path().join("src"); |
| 143 | fs::create_dir_all(&sub_dir).unwrap(); |
| 144 | let target_file = dir.path().join("vendor/autoload.php"); |
| 145 | fs::create_dir_all(target_file.parent().unwrap()).unwrap(); |
| 146 | fs::write(&target_file, "<?php // autoload").unwrap(); |
| 147 | |
| 148 | let main_content = "<?php\nrequire_once dirname(__DIR__) . '/vendor/autoload.php';\n"; |
| 149 | let main_uri = format!("file://{}", sub_dir.join("main.php").to_string_lossy()); |
| 150 | |
| 151 | let backend = create_test_backend(); |
| 152 | let links = get_document_links(&backend, &main_uri, main_content); |
| 153 | |
| 154 | assert_eq!( |
| 155 | links.len(), |
| 156 | 1, |
| 157 | "Expected one dirname(__DIR__) link, got: {:?}", |
| 158 | link_targets(&links) |
| 159 | ); |
| 160 | let target = links[0].target.as_ref().unwrap(); |
| 161 | let target_path = target.to_file_path().unwrap(); |
| 162 | assert!( |
| 163 | target_path.ends_with("vendor/autoload.php"), |
| 164 | "Expected link to vendor/autoload.php, got: {:?}", |
| 165 | target_path |
| 166 | ); |
| 167 | } |
| 168 | |
| 169 | #[test] |
| 170 | fn no_link_for_nonexistent_file() { |
nothing calls this directly
no test coverage detected