This repository was archived by the owner on Mar 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathHoverHandlerTest.php
More file actions
95 lines (79 loc) · 2.25 KB
/
Copy pathHoverHandlerTest.php
File metadata and controls
95 lines (79 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace Phpactor\Extension\LanguageServerHover\Tests\Unit\Handler;
use Phpactor\Extension\LanguageServerBridge\Converter\PositionConverter;
use Phpactor\LanguageServerProtocol\Hover;
use Phpactor\LanguageServerProtocol\TextDocumentIdentifier;
use Phpactor\Extension\LanguageServerCompletion\Tests\IntegrationTestCase;
use Phpactor\TestUtils\ExtractOffset;
use Phpactor\TextDocument\ByteOffset;
class HoverHandlerTest extends IntegrationTestCase
{
const PATH = 'file:///hello';
/**
* @dataProvider provideHover
*/
public function testHover(string $test): void
{
[ $text, $offset ] = ExtractOffset::fromSource($test);
$tester = $this->createTester();
$tester->textDocument()->open(self::PATH, $text);
$response = $tester->requestAndWait('textDocument/hover', [
'textDocument' => new TextDocumentIdentifier(self::PATH),
'position' => PositionConverter::byteOffsetToPosition(ByteOffset::fromInt((int)$offset), $text)
]);
$tester->assertSuccess($response);
$result = $response->result;
$this->assertInstanceOf(Hover::class, $result);
}
public function provideHover()
{
yield 'var' => [
'<?php $foo = "foo"; $f<>oo;',
];
yield 'poperty' => [
'<?php class A { private $<>b; }',
];
yield 'method' => [
'<?php class A { private function f<>oo():string {} }',
];
yield 'method with documentation' => [
<<<'EOT'
<?php
class A {
/**
* This is a method
*/
private function f<>oo():string {}
}
EOT
,
];
yield 'method with parent documentation' => [
<<<'EOT'
<?php
class Foobar {
/**
* The original documentation
*/
private function foo():string {}
}
class A extends Foobar {
/**
* This is a method
*/
private function f<>oo():string {}
}
EOT
,
];
yield 'class' => [
'<?php cl<>ass A { } }',
];
yield 'function' => [
'<?php function foo() {} f<>oo();',
];
yield 'namespaced function' => [
'<?php namespace Barf {function foo() {}} Barf\f<>oo();',
];
}
}