Skip to content

Commit ee5a7d7

Browse files
committed
Add tests for caching packages based on version, reference/revision
1 parent ad077ba commit ee5a7d7

File tree

5 files changed

+74
-1
lines changed

5 files changed

+74
-1
lines changed

fixtures/composer.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"require": {
3+
"example/example-version": "1.0.7",
4+
"example/example-reference": "dev-master"
5+
}
6+
}

fixtures/composer.lock

+55
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+

tests/LanguageServerTest.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,27 @@ public function testIndexingWithDirectFileAccess()
5353
$promise = new Promise;
5454
$input = new MockProtocolStream;
5555
$output = new MockProtocolStream;
56-
$output->on('message', function (Message $msg) use ($promise) {
56+
$cacheVersionCalled = false;
57+
$cacheReferenceCalled = false;
58+
$output->on('message', function (Message $msg) use ($promise, &$cacheVersionCalled, &$cacheReferenceCalled) {
5759
if ($msg->body->method === 'window/logMessage' && $promise->state === Promise::PENDING) {
5860
if ($msg->body->params->type === MessageType::ERROR) {
5961
$promise->reject(new Exception($msg->body->params->message));
6062
} else if (preg_match('/All [0-9]+ PHP files parsed/', $msg->body->params->message)) {
6163
$promise->fulfill();
64+
} else if (preg_match('#(Storing|Restored) example/example-version:.* (in|from) cache#', $msg->body->params->message)) {
65+
$cacheVersionCalled = true;
66+
} else if (preg_match('#(Storing|Restored) example/example-reference:.* (in|from) cache#', $msg->body->params->message)) {
67+
$cacheReferenceCalled = true;
6268
}
6369
}
6470
});
6571
$server = new LanguageServer($input, $output);
6672
$capabilities = new ClientCapabilities;
6773
$server->initialize($capabilities, realpath(__DIR__ . '/../fixtures'), getmypid());
6874
$promise->wait();
75+
$this->assertTrue($cacheVersionCalled);
76+
$this->assertTrue($cacheReferenceCalled);
6977
}
7078

7179
public function testIndexingWithFilesAndContentRequests()

0 commit comments

Comments
 (0)