Added test for didChange event
parent
0b15abcac5
commit
6688e9e29f
|
@ -123,4 +123,14 @@ class PhpDocument
|
|||
$edit->newText = $prettyPrinter->prettyPrintFile($stmts);
|
||||
return [$edit];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this document's text content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ 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 LanguageServer\Protocol\{TextDocumentItem, TextDocumentIdentifier, SymbolKind, DiagnosticSeverity, FormattingOptions, VersionedTextDocumentIdentifier, TextDocumentContentChangeEvent, Range, Position};
|
||||
use AdvancedJsonRpc\{Request as RequestBody, Response as ResponseBody};
|
||||
|
||||
class TextDocumentTest extends TestCase
|
||||
|
@ -218,4 +218,24 @@ class TextDocumentTest extends TestCase
|
|||
'newText' => $expected
|
||||
]], json_decode(json_encode($result), true));
|
||||
}
|
||||
|
||||
public function testDidChange()
|
||||
{
|
||||
$client = new LanguageClient(new MockProtocolStream());
|
||||
$project = new Project($client);
|
||||
$textDocument = new Server\TextDocument($project, $client);
|
||||
|
||||
$phpDocument = $project->getDocument('whatever');
|
||||
$phpDocument->updateContent("<?php\necho 'Hello, World'\n");
|
||||
|
||||
$identifier = new VersionedTextDocumentIdentifier('whatever');
|
||||
$changeEvent = new TextDocumentContentChangeEvent();
|
||||
$changeEvent->range = new Range(new Position(0,0), new Position(9999,9999));
|
||||
$changeEvent->rangeLength = 9999;
|
||||
$changeEvent->text = "<?php\necho 'Goodbye, World'\n";
|
||||
|
||||
$textDocument->didChange($identifier, [$changeEvent]);
|
||||
|
||||
$this->assertEquals("<?php\necho 'Goodbye, World'\n", $phpDocument->getContent());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue