Skip to content

Commit 5d2ab8f

Browse files
cweagansfelixfbecker
authored andcommitted
Add test for #211 (#270)
1 parent 3856f4f commit 5d2ab8f

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

fixtures/completion/bare_php.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
$abc = 1;
4+
$abc2 = 2;
5+
echo $ab

tests/LanguageServerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testIndexingWithDirectFileAccess()
5757
if ($msg->body->method === 'window/logMessage' && $promise->state === Promise::PENDING) {
5858
if ($msg->body->params->type === MessageType::ERROR) {
5959
$promise->reject(new Exception($msg->body->params->message));
60-
} else if (strpos($msg->body->params->message, 'All 25 PHP files parsed') !== false) {
60+
} else if (strpos($msg->body->params->message, 'All 26 PHP files parsed') !== false) {
6161
$promise->fulfill();
6262
}
6363
}
@@ -103,7 +103,7 @@ public function testIndexingWithFilesAndContentRequests()
103103
if ($promise->state === Promise::PENDING) {
104104
$promise->reject(new Exception($msg->body->params->message));
105105
}
106-
} else if (strpos($msg->body->params->message, 'All 25 PHP files parsed') !== false) {
106+
} else if (strpos($msg->body->params->message, 'All 26 PHP files parsed') !== false) {
107107
$promise->fulfill();
108108
}
109109
}

tests/Server/TextDocument/CompletionTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,4 +433,36 @@ public function testNamespace()
433433
)
434434
], true), $items);
435435
}
436+
437+
public function testBarePhp()
438+
{
439+
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/bare_php.php');
440+
$this->loader->open($completionUri, file_get_contents($completionUri));
441+
$items = $this->textDocument->completion(
442+
new TextDocumentIdentifier($completionUri),
443+
new Position(4, 8)
444+
)->wait();
445+
$this->assertEquals(new CompletionList([
446+
new CompletionItem(
447+
'$abc2',
448+
CompletionItemKind::VARIABLE,
449+
'int',
450+
null,
451+
null,
452+
null,
453+
null,
454+
new TextEdit(new Range(new Position(4, 8), new Position(4, 8)), 'c2')
455+
),
456+
new CompletionItem(
457+
'$abc',
458+
CompletionItemKind::VARIABLE,
459+
'int',
460+
null,
461+
null,
462+
null,
463+
null,
464+
new TextEdit(new Range(new Position(4, 8), new Position(4, 8)), 'c')
465+
)
466+
], true), $items);
467+
}
436468
}

0 commit comments

Comments
 (0)