1
0
Fork 0
php-language-server/tests/Server/TextDocument/Definition/NamespacedTest.php

57 lines
1.9 KiB
PHP
Raw Normal View History

2016-10-08 12:59:08 +00:00
<?php
declare(strict_types = 1);
namespace LanguageServer\Tests\Server\TextDocument\Definition;
2016-10-08 12:59:08 +00:00
use LanguageServerProtocol\{TextDocumentIdentifier, Location};
use function LanguageServer\pathToUri;
2016-10-08 12:59:08 +00:00
class NamespacedTest extends GlobalTest
2016-10-08 12:59:08 +00:00
{
public function getReferenceLocations(string $fqn): array
2016-10-08 12:59:08 +00:00
{
return parent::getReferenceLocations('TestNamespace\\' . $fqn);
}
public function getDefinitionLocation(string $fqn): Location
{
return parent::getDefinitionLocation('TestNamespace\\' . $fqn);
}
public function testDefinitionForConstants()
{
// echo TEST_CONST;
// Get definition for TEST_CONST
$reference = $this->getReferenceLocations('TEST_CONST')[0];
$result = $this->textDocument->definition(
new TextDocumentIdentifier($reference->uri),
$reference->range->start
)->wait();
$this->assertEquals($this->getDefinitionLocation('TEST_CONST'), $result);
}
2016-10-08 12:59:08 +00:00
public function testDefinitionForClassLikeUseStatement()
{
// use TestNamespace\TestClass;
// Get definition for TestClass
$reference = $this->getReferenceLocations('TestClass')[7];
$result = $this->textDocument->definition(
new TextDocumentIdentifier($reference->uri),
$reference->range->start
)->wait();
$this->assertEquals($this->getDefinitionLocation('TestClass'), $result);
2016-10-08 12:59:08 +00:00
}
public function testDefinitionForClassLikeGroupUseStatement()
{
// use TestNamespace\{TestTrait, TestInterface};
// Get definition for TestInterface
$reference = $this->getReferenceLocations('TestClass')[1];
$result = $this->textDocument->definition(
new TextDocumentIdentifier($reference->uri),
$reference->range->start
)->wait();
$this->assertEquals($this->getDefinitionLocation('TestClass'), $result);
2016-10-08 12:59:08 +00:00
}
}