1
0
Fork 0

Add tests for caching packages based on version, reference/revision

pull/367/head
John S Long 2017-04-30 11:44:12 -05:00
parent ad077ba343
commit ee5a7d79a7
5 changed files with 74 additions and 1 deletions

6
fixtures/composer.json Normal file
View File

@ -0,0 +1,6 @@
{
"require": {
"example/example-version": "1.0.7",
"example/example-reference": "dev-master"
}
}

55
fixtures/composer.lock generated Normal file
View File

@ -0,0 +1,55 @@
{
"_readme": [
"This is a mock lock file for composer"
],
"content-hash": "3da868eb11c9a94f957057f73d2936ef",
"packages": [
{
"name": "example/example-version",
"version": "1.0.7",
"source": {
"type": "git",
"url": "https://example.com",
"reference": "b17e6153cb7f33c7e44eb59578dc12eee5dc8e12"
},
"require": {},
"require-dev": {},
"suggest": {},
"type": "library",
"extra": {},
"autoload": {},
"license": [],
"authors": [],
"description": "",
"keywords": [],
"time": "2017-03-06T11:59:08+00:00"
},
{
"name": "example/example-reference",
"version": "1.0.7",
"source": {
"type": "git",
"url": "https://example.com",
"reference": "b17e6153cb7f33c7e44eb59578dc12eee5dc8e12"
},
"require": {},
"require-dev": {},
"suggest": {},
"type": "library",
"extra": {},
"autoload": {},
"license": [],
"authors": [],
"description": "",
"keywords": [],
"time": "2017-03-06T11:59:08+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "dev",
"prefer-stable": true,
"prefer-lowest": false,
"platform": {},
"platform-dev": []
}

View File

@ -0,0 +1 @@
<?php

View File

@ -0,0 +1,3 @@
<?php

View File

@ -53,12 +53,18 @@ class LanguageServerTest extends TestCase
$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;
}
}
});
@ -66,6 +72,8 @@ class LanguageServerTest extends TestCase
$capabilities = new ClientCapabilities;
$server->initialize($capabilities, realpath(__DIR__ . '/../fixtures'), getmypid());
$promise->wait();
$this->assertTrue($cacheVersionCalled);
$this->assertTrue($cacheReferenceCalled);
}
public function testIndexingWithFilesAndContentRequests()