1
0
Fork 0

Add more tests

pull/52/head
Felix Becker 2016-10-11 20:51:55 +02:00
parent ccfbf9c8f2
commit 214495a473
2 changed files with 30 additions and 49 deletions

View File

@ -475,7 +475,7 @@ class PhpDocument
{
// Variables always stay in the boundary of the file and need to be searched inside their function scope
// by traversing the AST
if ($node instanceof Node\Expr\Variable) {
if ($node instanceof Node\Expr\Variable || $node instanceof Node\Param) {
if ($node->name instanceof Node\Expr) {
return null;
}

View File

@ -320,64 +320,45 @@ class NamespacedTest extends TestCase
], json_decode(json_encode($result), true));
}
public function testReferencesForParams()
public function testReferencesForFunctionParams()
{
$this->markTestIncomplete();
// echo $param;
// Get definition for $param
$result = $this->textDocument->definition(new TextDocumentIdentifier($this->referencesUri), new Position(16, 13));
// function whatever(TestClass $param): TestClass
// Get references for $param
$result = $this->textDocument->references(new ReferenceContext, new TextDocumentIdentifier($this->referencesUri), new Position(15, 32));
$this->assertEquals([
[
'uri' => $this->referencesUri,
'range' => [
'start' => [
'line' => 15,
'character' => 18
'line' => 16,
'character' => 9
],
'end' => [
'line' => 15,
'character' => 33
'line' => 16,
'character' => 15
]
]
], json_decode(json_encode($result), true));
}
public function testReferencesForUsedVariables()
{
$this->markTestIncomplete();
// echo $var;
// Get definition for $var
$result = $this->textDocument->definition(new TextDocumentIdentifier($this->referencesUri), new Position(20, 11));
$this->assertEquals([
'uri' => $this->referencesUri,
'range' => [
'start' => [
'line' => 19,
'character' => 22
],
'end' => [
'line' => 19,
'character' => 25
]
]
], json_decode(json_encode($result), true));
}
public function testReferencesForFunctions()
{
$this->markTestIncomplete();
// test_function();
// Get definition for test_function
$result = $this->textDocument->definition(new TextDocumentIdentifier($this->referencesUri), new Position(10, 4));
// function test_function()
// Get references for test_function
$result = $this->textDocument->references(new ReferenceContext, new TextDocumentIdentifier($this->symbolsUri), new Position(33, 16));
$this->assertEquals([
'uri' => $this->symbolsUri,
[
'uri' => $this->referencesUri,
'range' => [
'start' => [
'line' => 33,
'line' => 10,
'character' => 0
],
'end' => [
'line' => 36,
'character' => 0
'line' => 10,
'character' => 13
]
]
]
], json_decode(json_encode($result), true));