1
0
Fork 0

Add test for array access

pull/155/head
Felix Becker 2016-11-18 11:27:24 +01:00
parent d764b7d6cc
commit 241960a4f7
6 changed files with 27 additions and 7 deletions

View File

@ -37,3 +37,4 @@ if ($abc instanceof TestInterface) {
// Nested expression
$obj->testProperty->testMethod();
TestClass::$staticTestProperty[123]->testProperty;

View File

@ -30,7 +30,7 @@ class TestClass implements TestInterface
/**
* Lorem excepteur officia sit anim velit veniam enim.
*
* @var TestClass
* @var TestClass[]
*/
public static $staticTestProperty;

View File

@ -37,3 +37,4 @@ if ($abc instanceof TestInterface) {
// Nested expressions
$obj->testProperty->testMethod();
TestClass::$staticTestProperty[123]->testProperty;

View File

@ -30,7 +30,7 @@ class TestClass implements TestInterface
/**
* Lorem excepteur officia sit anim velit veniam enim.
*
* @var TestClass
* @var TestClass[]
*/
public static $staticTestProperty;

View File

@ -105,7 +105,8 @@ abstract class ServerTestCase extends TestCase
3 => new Location($referencesUri, new Range(new Position( 9, 5), new Position( 9, 14))), // TestClass::TEST_CLASS_CONST;
4 => new Location($referencesUri, new Range(new Position(21, 18), new Position(21, 27))), // function whatever(TestClass $param)
5 => new Location($referencesUri, new Range(new Position(21, 37), new Position(21, 46))), // function whatever(TestClass $param): TestClass
6 => new Location($useUri, new Range(new Position( 4, 4), new Position( 4, 27))), // use TestNamespace\TestClass;
6 => new Location($referencesUri, new Range(new Position(39, 0), new Position(39, 9))), // TestClass::$staticTestProperty[123]->testProperty;
7 => new Location($useUri, new Range(new Position( 4, 4), new Position( 4, 27))), // use TestNamespace\TestClass;
],
'TestNamespace\\TestInterface' => [
0 => new Location($symbolsUri, new Range(new Position(20, 27), new Position(20, 40))), // class TestClass implements TestInterface
@ -119,10 +120,12 @@ abstract class ServerTestCase extends TestCase
'TestNamespace\\TestClass::testProperty' => [
0 => new Location($symbolsUri, new Range(new Position(59, 8), new Position(59, 27))), // $this->testProperty = $testParameter;
1 => new Location($referencesUri, new Range(new Position( 6, 5), new Position( 6, 23))), // echo $obj->testProperty;
2 => new Location($referencesUri, new Range(new Position(38, 0), new Position(38, 18))) // $obj->testProperty->testMethod();
2 => new Location($referencesUri, new Range(new Position(38, 0), new Position(38, 18))), // $obj->testProperty->testMethod();
3 => new Location($referencesUri, new Range(new Position(39, 0), new Position(39, 49))) // TestClass::$staticTestProperty[123]->testProperty;
],
'TestNamespace\\TestClass::staticTestProperty' => [
0 => new Location($referencesUri, new Range(new Position( 8, 5), new Position( 8, 35)))
0 => new Location($referencesUri, new Range(new Position( 8, 5), new Position( 8, 35))), // echo TestClass::$staticTestProperty;
1 => new Location($referencesUri, new Range(new Position(39, 0), new Position(39, 30))) // TestClass::$staticTestProperty[123]->testProperty;
],
'TestNamespace\\TestClass::staticTestMethod()' => [
0 => new Location($referencesUri, new Range(new Position( 7, 0), new Position( 7, 29)))
@ -148,6 +151,7 @@ abstract class ServerTestCase extends TestCase
3 => new Location($globalReferencesUri, new Range(new Position( 9, 5), new Position( 9, 14))), // TestClass::TEST_CLASS_CONST;
4 => new Location($globalReferencesUri, new Range(new Position(21, 18), new Position(21, 27))), // function whatever(TestClass $param)
5 => new Location($globalReferencesUri, new Range(new Position(21, 37), new Position(21, 46))), // function whatever(TestClass $param): TestClass
6 => new Location($globalReferencesUri, new Range(new Position(39, 0), new Position(39, 9))), // TestClass::$staticTestProperty[123]->testProperty;
],
'TestInterface' => [
0 => new Location($globalSymbolsUri, new Range(new Position(20, 27), new Position(20, 40))), // class TestClass implements TestInterface
@ -161,10 +165,12 @@ abstract class ServerTestCase extends TestCase
'TestClass::testProperty' => [
0 => new Location($globalSymbolsUri, new Range(new Position(59, 8), new Position(59, 27))), // $this->testProperty = $testParameter;
1 => new Location($globalReferencesUri, new Range(new Position( 6, 5), new Position( 6, 23))), // echo $obj->testProperty;
2 => new Location($globalReferencesUri, new Range(new Position(38, 0), new Position(38, 18))) // $obj->testProperty->testMethod();
2 => new Location($globalReferencesUri, new Range(new Position(38, 0), new Position(38, 18))), // $obj->testProperty->testMethod();
3 => new Location($globalReferencesUri, new Range(new Position(39, 0), new Position(39, 49))) // TestClass::$staticTestProperty[123]->testProperty;
],
'TestClass::staticTestProperty' => [
0 => new Location($globalReferencesUri, new Range(new Position( 8, 5), new Position( 8, 35)))
0 => new Location($globalReferencesUri, new Range(new Position( 8, 5), new Position( 8, 35))), // echo TestClass::$staticTestProperty;
1 => new Location($globalReferencesUri, new Range(new Position(39, 0), new Position(39, 30))) // TestClass::$staticTestProperty[123]->testProperty;
],
'TestClass::staticTestMethod()' => [
0 => new Location($globalReferencesUri, new Range(new Position( 7, 0), new Position( 7, 29)))

View File

@ -304,4 +304,16 @@ class GlobalTest extends ServerTestCase
)->wait();
$this->assertEquals($this->getDefinitionLocation('TestClass::testMethod()'), $result);
}
public function testDefinitionForPropertyFetchOnArrayDimFetch()
{
// $obj->testProperty->testMethod();
// Get definition for testProperty
$reference = $this->getReferenceLocations('TestClass::testProperty')[3];
$result = $this->textDocument->definition(
new TextDocumentIdentifier($reference->uri),
$reference->range->end
)->wait();
$this->assertEquals($this->getDefinitionLocation('TestClass::testProperty'), $result);
}
}