Add more tests
parent
ccfbf9c8f2
commit
214495a473
|
@ -475,7 +475,7 @@ class PhpDocument
|
||||||
{
|
{
|
||||||
// Variables always stay in the boundary of the file and need to be searched inside their function scope
|
// Variables always stay in the boundary of the file and need to be searched inside their function scope
|
||||||
// by traversing the AST
|
// 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) {
|
if ($node->name instanceof Node\Expr) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,64 +320,45 @@ class NamespacedTest extends TestCase
|
||||||
], json_decode(json_encode($result), true));
|
], json_decode(json_encode($result), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReferencesForParams()
|
public function testReferencesForFunctionParams()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
// function whatever(TestClass $param): TestClass
|
||||||
// echo $param;
|
// Get references for $param
|
||||||
// Get definition for $param
|
$result = $this->textDocument->references(new ReferenceContext, new TextDocumentIdentifier($this->referencesUri), new Position(15, 32));
|
||||||
$result = $this->textDocument->definition(new TextDocumentIdentifier($this->referencesUri), new Position(16, 13));
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
|
[
|
||||||
'uri' => $this->referencesUri,
|
'uri' => $this->referencesUri,
|
||||||
'range' => [
|
'range' => [
|
||||||
'start' => [
|
'start' => [
|
||||||
'line' => 15,
|
'line' => 16,
|
||||||
'character' => 18
|
'character' => 9
|
||||||
],
|
],
|
||||||
'end' => [
|
'end' => [
|
||||||
'line' => 15,
|
'line' => 16,
|
||||||
'character' => 33
|
'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));
|
], json_decode(json_encode($result), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReferencesForFunctions()
|
public function testReferencesForFunctions()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
// function test_function()
|
||||||
// test_function();
|
// Get references for test_function
|
||||||
// Get definition for test_function
|
$result = $this->textDocument->references(new ReferenceContext, new TextDocumentIdentifier($this->symbolsUri), new Position(33, 16));
|
||||||
$result = $this->textDocument->definition(new TextDocumentIdentifier($this->referencesUri), new Position(10, 4));
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'uri' => $this->symbolsUri,
|
[
|
||||||
|
'uri' => $this->referencesUri,
|
||||||
'range' => [
|
'range' => [
|
||||||
'start' => [
|
'start' => [
|
||||||
'line' => 33,
|
'line' => 10,
|
||||||
'character' => 0
|
'character' => 0
|
||||||
],
|
],
|
||||||
'end' => [
|
'end' => [
|
||||||
'line' => 36,
|
'line' => 10,
|
||||||
'character' => 0
|
'character' => 13
|
||||||
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
], json_decode(json_encode($result), true));
|
], json_decode(json_encode($result), true));
|
||||||
|
|
Loading…
Reference in New Issue