Add test for indexing
parent
47472252a7
commit
25f300c157
|
@ -183,7 +183,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
} else {
|
||||
$duration = (int)(microtime(true) - $startTime);
|
||||
$mem = (int)(memory_get_usage(true) / (1024 * 1024));
|
||||
$this->client->window->logMessage(MessageType::INFO, "All PHP files parsed in $duration seconds. $mem MiB allocated.");
|
||||
$this->client->window->logMessage(MessageType::INFO, "All $numTotalFiles PHP files parsed in $duration seconds. $mem MiB allocated.");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -5,8 +5,10 @@ namespace LanguageServer\Tests;
|
|||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use LanguageServer\LanguageServer;
|
||||
use LanguageServer\Protocol\{Message, ClientCapabilities, TextDocumentSyncKind};
|
||||
use LanguageServer\Protocol\{Message, ClientCapabilities, TextDocumentSyncKind, MessageType};
|
||||
use AdvancedJsonRpc;
|
||||
use Sabre\Event\Promise;
|
||||
use function LanguageServer\pathToUri;
|
||||
|
||||
class LanguageServerTest extends TestCase
|
||||
{
|
||||
|
@ -46,4 +48,24 @@ class LanguageServerTest extends TestCase
|
|||
]
|
||||
], $msg->body->result);
|
||||
}
|
||||
|
||||
public function testIndexing()
|
||||
{
|
||||
$promise = new Promise;
|
||||
$input = new MockProtocolStream;
|
||||
$output = new MockProtocolStream;
|
||||
$output->on('message', function (Message $msg) use ($promise) {
|
||||
if ($msg->body->method === 'window/logMessage') {
|
||||
if ($msg->body->params->type === MessageType::ERROR) {
|
||||
$promise->reject();
|
||||
} else if (strpos($msg->body->params->message, 'All 10 PHP files parsed') !== false) {
|
||||
$promise->fulfill();
|
||||
}
|
||||
}
|
||||
});
|
||||
$server = new LanguageServer($input, $output);
|
||||
$capabilities = new ClientCapabilities;
|
||||
$server->initialize(getmypid(), $capabilities, realpath(__DIR__ . '/../fixtures'));
|
||||
$promise->wait();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue