MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / require_once_dirname_dir

Function require_once_dirname_dir

tests/integration/document_links.rs:140–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

138
139#[test]
140fn 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]
170fn no_link_for_nonexistent_file() {

Callers

nothing calls this directly

Calls 3

create_test_backendFunction · 0.85
get_document_linksFunction · 0.85
unwrapMethod · 0.45

Tested by

no test coverage detected