2016-09-30 09:30:08 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
namespace LanguageServer\Tests\Server;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use LanguageServer\Tests\MockProtocolStream;
|
|
|
|
use LanguageServer\{Server, Client, LanguageClient, Project, PhpDocument};
|
|
|
|
use LanguageServer\Protocol\{TextDocumentItem, TextDocumentIdentifier, SymbolKind, DiagnosticSeverity, FormattingOptions};
|
|
|
|
use AdvancedJsonRpc\{Request as RequestBody, Response as ResponseBody};
|
2016-10-11 12:42:56 +00:00
|
|
|
use function LanguageServer\pathToUri;
|
2016-09-30 09:30:08 +00:00
|
|
|
|
|
|
|
class ProjectTest 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));
|
2016-09-30 09:30:08 +00:00
|
|
|
}
|
|
|
|
|
2016-10-11 12:42:56 +00:00
|
|
|
public function testGetDocumentLoadsDocument()
|
2016-09-30 09:30:08 +00:00
|
|
|
{
|
2016-10-11 12:42:56 +00:00
|
|
|
$document = $this->project->getDocument(pathToUri(__FILE__));
|
2016-09-30 09:30:08 +00:00
|
|
|
|
|
|
|
$this->assertNotNull($document);
|
|
|
|
$this->assertInstanceOf(PhpDocument::class, $document);
|
|
|
|
}
|
|
|
|
|
2016-10-11 12:42:56 +00:00
|
|
|
public function testGetDocumentReturnsOpenedInstance()
|
2016-09-30 09:30:08 +00:00
|
|
|
{
|
2016-10-11 12:42:56 +00:00
|
|
|
$document1 = $this->project->openDocument(pathToUri(__FILE__), file_get_contents(__FILE__));
|
|
|
|
$document2 = $this->project->getDocument(pathToUri(__FILE__));
|
2016-09-30 09:30:08 +00:00
|
|
|
|
|
|
|
$this->assertSame($document1, $document2);
|
|
|
|
}
|
|
|
|
}
|