2016-09-02 19:13:30 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
2016-10-08 12:51:49 +00:00
|
|
|
namespace LanguageServer\Tests\Server\TextDocument;
|
2016-09-02 19:13:30 +00:00
|
|
|
|
2016-10-18 21:09:51 +00:00
|
|
|
use LanguageServer\Tests\Server\ServerTestCase;
|
2016-09-02 19:13:30 +00:00
|
|
|
use LanguageServer\Tests\MockProtocolStream;
|
2016-10-08 12:51:49 +00:00
|
|
|
use LanguageServer\{Server, LanguageClient, Project};
|
2016-10-18 21:09:51 +00:00
|
|
|
use LanguageServer\Protocol\{TextDocumentIdentifier, SymbolInformation, SymbolKind, Position, Location, Range};
|
|
|
|
use function LanguageServer\pathToUri;
|
2016-09-02 19:13:30 +00:00
|
|
|
|
2016-10-18 21:09:51 +00:00
|
|
|
class DocumentSymbolTest extends ServerTestCase
|
2016-09-02 19:13:30 +00:00
|
|
|
{
|
2016-10-08 12:51:49 +00:00
|
|
|
public function test()
|
|
|
|
{
|
2016-09-02 19:13:30 +00:00
|
|
|
// Request symbols
|
2016-10-18 21:09:51 +00:00
|
|
|
$uri = pathToUri(realpath(__DIR__ . '/../../../fixtures/symbols.php'));
|
|
|
|
$result = $this->textDocument->documentSymbol(new TextDocumentIdentifier($uri));
|
2016-09-02 19:13:30 +00:00
|
|
|
$this->assertEquals([
|
2016-10-18 21:09:51 +00:00
|
|
|
new SymbolInformation('TEST_CONST', SymbolKind::CONSTANT, $this->getDefinitionLocation('TestNamespace\\TEST_CONST'), 'TestNamespace'),
|
|
|
|
new SymbolInformation('TestClass', SymbolKind::CLASS_, $this->getDefinitionLocation('TestNamespace\\TestClass'), 'TestNamespace'),
|
|
|
|
new SymbolInformation('TEST_CLASS_CONST', SymbolKind::CONSTANT, $this->getDefinitionLocation('TestNamespace\\TestClass::TEST_CLASS_CONST'), 'TestNamespace\\TestClass'),
|
|
|
|
new SymbolInformation('staticTestProperty', SymbolKind::FIELD, $this->getDefinitionLocation('TestNamespace\\TestClass::staticTestProperty'), 'TestNamespace\\TestClass'),
|
|
|
|
new SymbolInformation('testProperty', SymbolKind::FIELD, $this->getDefinitionLocation('TestNamespace\\TestClass::testProperty'), 'TestNamespace\\TestClass'),
|
|
|
|
new SymbolInformation('staticTestMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestNamespace\\TestClass::staticTestMethod()'), 'TestNamespace\\TestClass'),
|
|
|
|
new SymbolInformation('testMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestNamespace\\TestClass::testMethod()'), 'TestNamespace\\TestClass'),
|
|
|
|
new SymbolInformation('TestTrait', SymbolKind::CLASS_, $this->getDefinitionLocation('TestNamespace\\TestTrait'), 'TestNamespace'),
|
|
|
|
new SymbolInformation('TestInterface', SymbolKind::INTERFACE, $this->getDefinitionLocation('TestNamespace\\TestInterface'), 'TestNamespace'),
|
|
|
|
new SymbolInformation('test_function', SymbolKind::FUNCTION, $this->getDefinitionLocation('TestNamespace\\test_function()'), 'TestNamespace'),
|
|
|
|
], $result);
|
2016-09-02 19:13:30 +00:00
|
|
|
}
|
|
|
|
}
|