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

Function test_parse_php_extracts_properties

tests/integration/parser.rs:45–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43
44#[tokio::test]
45async fn test_parse_php_extracts_properties() {
46 let backend = create_test_backend();
47 let php = concat!(
48 "<?php\n",
49 "class User {\n",
50 " public string $name;\n",
51 " public int $age;\n",
52 " private $secret;\n",
53 " function login() {}\n",
54 "}\n",
55 );
56
57 let classes = backend.parse_php(php);
58 assert_eq!(classes.len(), 1);
59 assert_eq!(
60 classes[0].properties.len(),
61 3,
62 "Should extract 3 properties"
63 );
64
65 let prop_names: Vec<&str> = classes[0]
66 .properties
67 .iter()
68 .map(|p| p.name.as_str())
69 .collect();
70 assert!(prop_names.contains(&"name"), "Should contain 'name'");
71 assert!(prop_names.contains(&"age"), "Should contain 'age'");
72 assert!(prop_names.contains(&"secret"), "Should contain 'secret'");
73
74 // Verify type hints
75 let name_prop = classes[0]
76 .properties
77 .iter()
78 .find(|p| p.name == "name")
79 .unwrap();
80 assert_eq!(
81 name_prop.type_hint_str().as_deref(),
82 Some("string"),
83 "name property should have string type hint"
84 );
85
86 let age_prop = classes[0]
87 .properties
88 .iter()
89 .find(|p| p.name == "age")
90 .unwrap();
91 assert_eq!(
92 age_prop.type_hint_str().as_deref(),
93 Some("int"),
94 "age property should have int type hint"
95 );
96
97 let secret_prop = classes[0]
98 .properties
99 .iter()
100 .find(|p| p.name == "secret")
101 .unwrap();
102 assert_eq!(

Callers

nothing calls this directly

Calls 7

create_test_backendFunction · 0.85
parse_phpMethod · 0.80
iterMethod · 0.80
as_strMethod · 0.80
mapMethod · 0.45
unwrapMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected