1
0
Fork 0

Add test for indexing

pull/38/merge
Felix Becker 2016-11-07 11:52:24 +01:00
parent 47472252a7
commit 25f300c157
2 changed files with 24 additions and 2 deletions

View File

@ -183,7 +183,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
} else { } else {
$duration = (int)(microtime(true) - $startTime); $duration = (int)(microtime(true) - $startTime);
$mem = (int)(memory_get_usage(true) / (1024 * 1024)); $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.");
} }
}; };

View File

@ -5,8 +5,10 @@ namespace LanguageServer\Tests;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use LanguageServer\LanguageServer; use LanguageServer\LanguageServer;
use LanguageServer\Protocol\{Message, ClientCapabilities, TextDocumentSyncKind}; use LanguageServer\Protocol\{Message, ClientCapabilities, TextDocumentSyncKind, MessageType};
use AdvancedJsonRpc; use AdvancedJsonRpc;
use Sabre\Event\Promise;
use function LanguageServer\pathToUri;
class LanguageServerTest extends TestCase class LanguageServerTest extends TestCase
{ {
@ -46,4 +48,24 @@ class LanguageServerTest extends TestCase
] ]
], $msg->body->result); ], $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();
}
} }