-
Notifications
You must be signed in to change notification settings - Fork 186
/
Copy pathPhpDocumentLoaderTest.php
48 lines (40 loc) Β· 1.27 KB
/
PhpDocumentLoaderTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types = 1);
namespace LanguageServer\Tests\Server;
use LanguageServer\{
PhpDocument, PhpDocumentLoader, Project, DefinitionResolver
};
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
use LanguageServer\Index\{
DependenciesIndex, Index, ProjectIndex
};
use PHPUnit\Framework\TestCase;
use function LanguageServer\pathToUri;
class PhpDocumentLoaderTest extends TestCase
{
/**
* @var PhpDocumentLoader
*/
private $loader;
public function setUp()
{
$projectIndex = new ProjectIndex(new Index, new DependenciesIndex);
$this->loader = new PhpDocumentLoader(
new FileSystemContentRetriever,
$projectIndex,
new DefinitionResolver($projectIndex)
);
}
public function testGetOrLoadLoadsDocument()
{
$document = $this->loader->getOrLoad(pathToUri(__FILE__))->wait();
$this->assertNotNull($document);
$this->assertInstanceOf(PhpDocument::class, $document);
}
public function testGetReturnsOpenedInstance()
{
$document1 = $this->loader->open(pathToUri(__FILE__), file_get_contents(__FILE__));
$document2 = $this->loader->get(pathToUri(__FILE__));
$this->assertSame($document1, $document2);
}
}