Skip to content
This repository was archived by the owner on Mar 6, 2022. It is now read-only.

Commit 06b3755

Browse files
committed
Merge branch 'allow-disable-selected-capabilities-by-the-client' of przepompownia:przepompownia/language-server-phpactor-extensions into allow-disable-selected-capabilities-by-the-client
2 parents c34bac9 + 619ad40 commit 06b3755

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

tests/LanguageServerCompletion/Unit/Handler/CompletionHandlerTest.php

+31-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,34 @@ public function testHandleNoSuggestions(): void
4949
$this->assertFalse($response->result->isIncomplete);
5050
}
5151

52+
public function testHandleWithDisabledCapability(): void
53+
{
54+
$tester = $this->create(
55+
[
56+
Suggestion::create('hello'),
57+
Suggestion::create('goodbye'),
58+
],
59+
true,
60+
false,
61+
[],
62+
[],
63+
false
64+
);
65+
$response = $tester->requestAndWait(
66+
'textDocument/completion',
67+
[
68+
'textDocument' => ProtocolFactory::textDocumentIdentifier(self::EXAMPLE_URI),
69+
'position' => ProtocolFactory::position(0, 0)
70+
]
71+
);
72+
$this->assertInstanceOf(CompletionList::class, $response->result);
73+
$this->assertEquals([
74+
self::completionItem('hello', null),
75+
self::completionItem('goodbye', null),
76+
], $response->result->items);
77+
$this->assertFalse($response->result->isIncomplete);
78+
}
79+
5280
public function testHandleACompleteListOfSuggestions(): void
5381
{
5482
$tester = $this->create([
@@ -380,7 +408,8 @@ private function create(
380408
bool $supportSnippets = true,
381409
bool $isIncomplete = false,
382410
array $importNameTextEdits = [],
383-
array $aliases = []
411+
array $aliases = [],
412+
bool $supportCompletion = true
384413
): LanguageServerTester {
385414
$completor = $this->createCompletor($suggestions, $isIncomplete);
386415
$registry = new TypedCompletorRegistry([
@@ -392,7 +421,7 @@ private function create(
392421
$registry,
393422
new SuggestionNameFormatter(true),
394423
$this->createNameImporter($suggestions, $aliases, $importNameTextEdits),
395-
$this->createClientCapabilities(true, $supportSnippets),
424+
$this->createClientCapabilities($supportCompletion, $supportSnippets),
396425
true
397426
))->build();
398427
$tester->textDocument()->open(self::EXAMPLE_URI, self::EXAMPLE_TEXT);

0 commit comments

Comments
 (0)