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

55 lines
1.6 KiB
PHP
Raw Normal View History

<?php
declare(strict_types = 1);
namespace LanguageServer\Tests\Server;
use PHPUnit\Framework\TestCase;
use LanguageServer\Tests\MockProtocolStream;
2016-12-12 21:59:08 +00:00
use LanguageServer\{Server, Client, LanguageClient, Project, PhpDocument, PhpDocumentLoader, DefinitionResolver};
2016-12-08 01:33:48 +00:00
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
2016-12-12 21:59:08 +00:00
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
use LanguageServer\Protocol\{
TextDocumentItem,
TextDocumentIdentifier,
SymbolKind,
DiagnosticSeverity,
FormattingOptions,
ClientCapabilities
};
use AdvancedJsonRpc\{Request as RequestBody, Response as ResponseBody};
use function LanguageServer\pathToUri;
2016-12-12 21:59:08 +00:00
class PhpDocumentLoaderTest extends TestCase
{
/**
2016-12-12 21:59:08 +00:00
* @var PhpDocumentLoader
*/
2016-12-12 21:59:08 +00:00
private $loader;
public function setUp()
{
2016-12-12 21:59:08 +00:00
$projectIndex = new ProjectIndex(new Index, new DependenciesIndex);
$this->loader = new PhpDocumentLoader(
new FileSystemContentRetriever,
$projectIndex,
new DefinitionResolver($projectIndex)
);
}
2016-12-12 21:59:08 +00:00
public function testGetOrLoadLoadsDocument()
{
2016-12-12 21:59:08 +00:00
$document = $this->loader->getOrLoad(pathToUri(__FILE__))->wait();
$this->assertNotNull($document);
$this->assertInstanceOf(PhpDocument::class, $document);
}
2016-12-12 21:59:08 +00:00
public function testGetReturnsOpenedInstance()
{
2016-12-12 21:59:08 +00:00
$document1 = $this->loader->open(pathToUri(__FILE__), file_get_contents(__FILE__));
$document2 = $this->loader->get(pathToUri(__FILE__));
$this->assertSame($document1, $document2);
}
}