1
0
Fork 0

Add test for #211 (#270)

pull/307/head
Cameron Eagans 2017-02-15 08:25:06 -08:00 committed by Felix Becker
parent 3856f4f46a
commit 5d2ab8f369
3 changed files with 39 additions and 2 deletions

View File

@ -0,0 +1,5 @@
<?php
$abc = 1;
$abc2 = 2;
echo $ab

View File

@ -57,7 +57,7 @@ class LanguageServerTest extends TestCase
if ($msg->body->method === 'window/logMessage' && $promise->state === Promise::PENDING) { if ($msg->body->method === 'window/logMessage' && $promise->state === Promise::PENDING) {
if ($msg->body->params->type === MessageType::ERROR) { if ($msg->body->params->type === MessageType::ERROR) {
$promise->reject(new Exception($msg->body->params->message)); $promise->reject(new Exception($msg->body->params->message));
} else if (strpos($msg->body->params->message, 'All 25 PHP files parsed') !== false) { } else if (strpos($msg->body->params->message, 'All 26 PHP files parsed') !== false) {
$promise->fulfill(); $promise->fulfill();
} }
} }
@ -103,7 +103,7 @@ class LanguageServerTest extends TestCase
if ($promise->state === Promise::PENDING) { if ($promise->state === Promise::PENDING) {
$promise->reject(new Exception($msg->body->params->message)); $promise->reject(new Exception($msg->body->params->message));
} }
} else if (strpos($msg->body->params->message, 'All 25 PHP files parsed') !== false) { } else if (strpos($msg->body->params->message, 'All 26 PHP files parsed') !== false) {
$promise->fulfill(); $promise->fulfill();
} }
} }

View File

@ -433,4 +433,36 @@ class CompletionTest extends TestCase
) )
], true), $items); ], true), $items);
} }
public function testBarePhp()
{
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/bare_php.php');
$this->loader->open($completionUri, file_get_contents($completionUri));
$items = $this->textDocument->completion(
new TextDocumentIdentifier($completionUri),
new Position(4, 8)
)->wait();
$this->assertEquals(new CompletionList([
new CompletionItem(
'$abc2',
CompletionItemKind::VARIABLE,
'int',
null,
null,
null,
null,
new TextEdit(new Range(new Position(4, 8), new Position(4, 8)), 'c2')
),
new CompletionItem(
'$abc',
CompletionItemKind::VARIABLE,
'int',
null,
null,
null,
null,
new TextEdit(new Range(new Position(4, 8), new Position(4, 8)), 'c')
)
], true), $items);
}
} }