@@ -4,6 +4,73 @@ use common::{create_psr4_workspace, create_test_backend};
44use tower_lsp:: LanguageServer ;
55use tower_lsp:: lsp_types:: * ;
66
7+ /// Test: BackedEnum completion includes `name` and `value` properties.
8+ #[ tokio:: test]
9+ async fn test_backed_enum_completion_includes_name_and_value ( ) {
10+ let backend = create_test_backend ( ) ;
11+
12+ let uri = Url :: parse ( "file:///backed_enum.php" ) . unwrap ( ) ;
13+ let text = concat ! (
14+ "<?php\n " ,
15+ "enum Status: string {\n " ,
16+ " case Active = 'active';\n " ,
17+ " public function label(): string {\n " ,
18+ " $this->\n " ,
19+ " }\n " ,
20+ "}\n " ,
21+ ) ;
22+
23+ backend
24+ . did_open ( DidOpenTextDocumentParams {
25+ text_document : TextDocumentItem {
26+ uri : uri. clone ( ) ,
27+ language_id : "php" . to_string ( ) ,
28+ version : 1 ,
29+ text : text. to_string ( ) ,
30+ } ,
31+ } )
32+ . await ;
33+
34+ let result = backend
35+ . completion ( CompletionParams {
36+ text_document_position : TextDocumentPositionParams {
37+ text_document : TextDocumentIdentifier { uri } ,
38+ position : Position {
39+ line : 4 ,
40+ character : 15 ,
41+ } ,
42+ } ,
43+ work_done_progress_params : WorkDoneProgressParams :: default ( ) ,
44+ partial_result_params : PartialResultParams :: default ( ) ,
45+ context : None ,
46+ } )
47+ . await
48+ . unwrap ( ) ;
49+
50+ assert ! ( result. is_some( ) , "Completion should return results" ) ;
51+ match result. unwrap ( ) {
52+ CompletionResponse :: Array ( items) => {
53+ let property_names: Vec < & str > = items
54+ . iter ( )
55+ . filter ( |i| i. kind == Some ( CompletionItemKind :: PROPERTY ) )
56+ . map ( |i| i. filter_text . as_deref ( ) . unwrap ( ) )
57+ . collect ( ) ;
58+
59+ assert ! (
60+ property_names. contains( & "name" ) ,
61+ "BackedEnum completion should include 'name' property, got: {:?}" ,
62+ property_names
63+ ) ;
64+ assert ! (
65+ property_names. contains( & "value" ) ,
66+ "BackedEnum completion should include 'value' property, got: {:?}" ,
67+ property_names
68+ ) ;
69+ }
70+ _ => panic ! ( "Expected CompletionResponse::Array" ) ,
71+ }
72+ }
73+
774// ─── Basic enum case completion via :: ──────────────────────────────────────
875
976/// Test: Completing on `EnumName::` should show enum cases as constants.
0 commit comments