Skip to content

Commit

Permalink
Add tests for caching packages based on version, reference/revision
Browse files Browse the repository at this point in the history
  • Loading branch information
John S Long committed Apr 30, 2017
1 parent 6daa434 commit 54831bc
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 1 deletion.
6 changes: 6 additions & 0 deletions fixtures/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"example/example-version": "1.0.7",
"example/example-reference": "dev-master"
}
}
55 changes: 55 additions & 0 deletions fixtures/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions fixtures/vendor/example/example-reference/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
3 changes: 3 additions & 0 deletions fixtures/vendor/example/example-version/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php


10 changes: 9 additions & 1 deletion tests/LanguageServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,27 @@ public function testIndexingWithDirectFileAccess()
$promise = new Promise;
$input = new MockProtocolStream;
$output = new MockProtocolStream;
$output->on('message', function (Message $msg) use ($promise) {
$cacheVersionCalled = false;
$cacheReferenceCalled = false;
$output->on('message', function (Message $msg) use ($promise, &$cacheVersionCalled, &$cacheReferenceCalled) {
if ($msg->body->method === 'window/logMessage' && $promise->state === Promise::PENDING) {
if ($msg->body->params->type === MessageType::ERROR) {
$promise->reject(new Exception($msg->body->params->message));
} else if (preg_match('/All [0-9]+ PHP files parsed/', $msg->body->params->message)) {
$promise->fulfill();
} else if (preg_match('#(Storing|Restored) example/example-version:.* (in|from) cache#', $msg->body->params->message)) {
$cacheVersionCalled = true;
} else if (preg_match('#(Storing|Restored) example/example-reference:.* (in|from) cache#', $msg->body->params->message)) {
$cacheReferenceCalled = true;
}
}
});
$server = new LanguageServer($input, $output);
$capabilities = new ClientCapabilities;
$server->initialize($capabilities, realpath(__DIR__ . '/../fixtures'), getmypid());
$promise->wait();
$this->assertTrue($cacheVersionCalled);
$this->assertTrue($cacheReferenceCalled);
}

public function testIndexingWithFilesAndContentRequests()
Expand Down

0 comments on commit 54831bc

Please sign in to comment.