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

52 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2019-06-18 08:59:40 +00:00
declare(strict_types=1);
namespace LanguageServer\Tests\Server;
2019-06-18 08:59:40 +00:00
use Amp\Loop;
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()
{
2019-06-18 08:59:40 +00:00
Loop::run(function () {
$document = yield from $this->loader->getOrLoad(pathToUri(__FILE__));
2019-06-18 08:59:40 +00:00
$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);
}
}