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

49 lines
1.3 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types = 1);
namespace LanguageServer\Tests\Server;
use LanguageServer\{
PhpDocument, PhpDocumentLoader, Project, DefinitionResolver
};
2016-12-08 01:33:48 +00:00
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
use LanguageServer\Index\{
DependenciesIndex, Index, ProjectIndex
};
use PHPUnit\Framework\TestCase;
use function LanguageServer\pathToUri;
2016-12-13 00:51:02 +00:00
class PhpDocumentLoaderTest extends TestCase
{
/**
2016-12-13 00:51:02 +00:00
* @var PhpDocumentLoader
*/
2016-12-13 00:51:02 +00:00
private $loader;
public function setUp()
{
2016-12-13 00:51:02 +00:00
$projectIndex = new ProjectIndex(new Index, new DependenciesIndex);
$this->loader = new PhpDocumentLoader(
new FileSystemContentRetriever,
$projectIndex,
new DefinitionResolver($projectIndex)
);
}
2016-12-13 00:51:02 +00:00
public function testGetOrLoadLoadsDocument()
{
2016-12-13 00:51:02 +00:00
$document = $this->loader->getOrLoad(pathToUri(__FILE__))->wait();
$this->assertNotNull($document);
$this->assertInstanceOf(PhpDocument::class, $document);
}
2016-12-13 00:51:02 +00:00
public function testGetReturnsOpenedInstance()
{
2016-12-13 00:51:02 +00:00
$document1 = $this->loader->open(pathToUri(__FILE__), file_get_contents(__FILE__));
$document2 = $this->loader->get(pathToUri(__FILE__));
$this->assertSame($document1, $document2);
}
}