made a mess of merge - revert CompletionTest to original
parent
1f827298c5
commit
0775c0728a
|
@ -554,6 +554,146 @@ class CompletionTest extends TestCase
|
||||||
], true), $items);
|
], true), $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider foreachProvider
|
||||||
|
*/
|
||||||
|
public function testForeach(Position $position, array $expectedItems)
|
||||||
|
{
|
||||||
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/foreach.php');
|
||||||
|
$this->loader->open($completionUri, file_get_contents($completionUri));
|
||||||
|
$items = $this->textDocument->completion(
|
||||||
|
new TextDocumentIdentifier($completionUri),
|
||||||
|
$position
|
||||||
|
)->wait();
|
||||||
|
$this->assertCompletionsListSubset(new CompletionList($expectedItems, true), $items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function foreachProvider(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'foreach value' => [
|
||||||
|
new Position(18, 6),
|
||||||
|
[
|
||||||
|
new CompletionItem(
|
||||||
|
'$value',
|
||||||
|
CompletionItemKind::VARIABLE,
|
||||||
|
'\\Foo\\Bar',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new TextEdit(new Range(new Position(18, 6), new Position(18, 6)), 'alue')
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'foreach value resolved' => [
|
||||||
|
new Position(19, 12),
|
||||||
|
[
|
||||||
|
new CompletionItem(
|
||||||
|
'foo',
|
||||||
|
CompletionItemKind::PROPERTY,
|
||||||
|
'mixed'
|
||||||
|
),
|
||||||
|
new CompletionItem(
|
||||||
|
'test',
|
||||||
|
CompletionItemKind::METHOD,
|
||||||
|
'\\Foo\\Bar[]'
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'array creation with multiple objects' => [
|
||||||
|
new Position(23, 5),
|
||||||
|
[
|
||||||
|
new CompletionItem(
|
||||||
|
'$value',
|
||||||
|
CompletionItemKind::VARIABLE,
|
||||||
|
'\\Foo\\Bar|\\stdClass',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new TextEdit(new Range(new Position(23, 5), new Position(23, 5)), 'value')
|
||||||
|
),
|
||||||
|
new CompletionItem(
|
||||||
|
'$key',
|
||||||
|
CompletionItemKind::VARIABLE,
|
||||||
|
'int',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new TextEdit(new Range(new Position(23, 5), new Position(23, 5)), 'key')
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'array creation with string/int keys and object values' => [
|
||||||
|
new Position(27, 5),
|
||||||
|
[
|
||||||
|
new CompletionItem(
|
||||||
|
'$value',
|
||||||
|
CompletionItemKind::VARIABLE,
|
||||||
|
'\\Foo\\Bar',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new TextEdit(new Range(new Position(27, 5), new Position(27, 5)), 'value')
|
||||||
|
),
|
||||||
|
new CompletionItem(
|
||||||
|
'$key',
|
||||||
|
CompletionItemKind::VARIABLE,
|
||||||
|
'string|int',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new TextEdit(new Range(new Position(27, 5), new Position(27, 5)), 'key')
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'array creation with only string keys' => [
|
||||||
|
new Position(31, 5),
|
||||||
|
[
|
||||||
|
new CompletionItem(
|
||||||
|
'$value',
|
||||||
|
CompletionItemKind::VARIABLE,
|
||||||
|
'\\Foo\\Bar',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new TextEdit(new Range(new Position(31, 5), new Position(31, 5)), 'value')
|
||||||
|
),
|
||||||
|
new CompletionItem(
|
||||||
|
'$key',
|
||||||
|
CompletionItemKind::VARIABLE,
|
||||||
|
'string',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new TextEdit(new Range(new Position(31, 5), new Position(31, 5)), 'key')
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'foreach function call' => [
|
||||||
|
new Position(35, 5),
|
||||||
|
[
|
||||||
|
new CompletionItem(
|
||||||
|
'$value',
|
||||||
|
CompletionItemKind::VARIABLE,
|
||||||
|
'\\Foo\\Bar',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new TextEdit(new Range(new Position(35, 5), new Position(35, 5)), 'value')
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function testMethodReturnType()
|
public function testMethodReturnType()
|
||||||
{
|
{
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/method_return_type.php');
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/method_return_type.php');
|
||||||
|
|
Loading…
Reference in New Issue