Add tests for static access
parent
151dea6ad1
commit
51de0b5dfc
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
TestClass::TE
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
TestClass::st
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
TestClass::$st
|
|
@ -290,6 +290,9 @@ class PhpDocument
|
|||
*/
|
||||
public function getNodeAtPosition(Position $position)
|
||||
{
|
||||
if ($this->stmts === null) {
|
||||
return null;
|
||||
}
|
||||
$traverser = new NodeTraverser;
|
||||
$finder = new NodeAtPositionFinder($position);
|
||||
$traverser->addVisitor($finder);
|
||||
|
|
|
@ -131,6 +131,60 @@ class CompletionTest extends TestCase
|
|||
], $items);
|
||||
}
|
||||
|
||||
public function testStaticPropertyWithPrefix()
|
||||
{
|
||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/static_property_with_prefix.php');
|
||||
$this->project->openDocument($completionUri, file_get_contents($completionUri));
|
||||
$items = $this->textDocument->completion(
|
||||
new TextDocumentIdentifier($completionUri),
|
||||
new Position(2, 14)
|
||||
)->wait();
|
||||
$this->assertEquals([
|
||||
new CompletionItem(
|
||||
'staticTestProperty',
|
||||
CompletionItemKind::PROPERTY,
|
||||
'\TestClass[]',
|
||||
'Lorem excepteur officia sit anim velit veniam enim.'
|
||||
)
|
||||
], $items);
|
||||
}
|
||||
|
||||
public function testStaticMethodWithPrefix()
|
||||
{
|
||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/static_method_with_prefix.php');
|
||||
$this->project->openDocument($completionUri, file_get_contents($completionUri));
|
||||
$items = $this->textDocument->completion(
|
||||
new TextDocumentIdentifier($completionUri),
|
||||
new Position(2, 13)
|
||||
)->wait();
|
||||
$this->assertEquals([
|
||||
new CompletionItem(
|
||||
'staticTestMethod',
|
||||
CompletionItemKind::METHOD,
|
||||
'mixed', // Method return type
|
||||
'Do magna consequat veniam minim proident eiusmod incididunt aute proident.'
|
||||
)
|
||||
], $items);
|
||||
}
|
||||
|
||||
public function testClassConstWithPrefix()
|
||||
{
|
||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/class_const_with_prefix.php');
|
||||
$this->project->openDocument($completionUri, file_get_contents($completionUri));
|
||||
$items = $this->textDocument->completion(
|
||||
new TextDocumentIdentifier($completionUri),
|
||||
new Position(2, 13)
|
||||
)->wait();
|
||||
$this->assertEquals([
|
||||
new CompletionItem(
|
||||
'TEST_CLASS_CONST',
|
||||
CompletionItemKind::VARIABLE,
|
||||
'int',
|
||||
'Anim labore veniam consectetur laboris minim quis aute aute esse nulla ad.'
|
||||
)
|
||||
], $items);
|
||||
}
|
||||
|
||||
public function testFullyQualifiedClass()
|
||||
{
|
||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/fully_qualified_class.php');
|
||||
|
|
Loading…
Reference in New Issue