1
0
Fork 0
php-language-server/tests/PhpDocumentTest.php

40 lines
1.1 KiB
PHP
Raw Normal View History

<?php
declare(strict_types = 1);
namespace LanguageServer\Tests\Server;
use PHPUnit\Framework\TestCase;
use LanguageServer\Tests\MockProtocolStream;
use LanguageServer\{LanguageClient, Project};
2016-10-09 14:03:56 +00:00
use LanguageServer\NodeVisitor\NodeAtPositionFinder;
use LanguageServer\Protocol\{SymbolKind, Position};
use PhpParser\Node;
class PhpDocumentTest extends TestCase
{
/**
* @var Project $project
*/
private $project;
public function setUp()
{
2016-10-31 10:47:21 +00:00
$this->project = new Project(new LanguageClient(new MockProtocolStream, new MockProtocolStream));
}
public function testParsesVariableVariables()
{
$document = $this->project->openDocument('whatever', "<?php\n$\$a = 'foo';\n\$bar = 'baz';\n");
$this->assertEquals([], $document->getDefinitions());
}
public function testGetNodeAtPosition()
{
$document = $this->project->openDocument('whatever', "<?php\n$\$a = new SomeClass;");
$node = $document->getNodeAtPosition(new Position(1, 13));
$this->assertInstanceOf(Node\Name\FullyQualified::class, $node);
$this->assertEquals('SomeClass', (string)$node);
}
}