From 1f827298c52fa2deaeb86a0b22be058417761f13 Mon Sep 17 00:00:00 2001 From: Philip Nelson Date: Sat, 23 Dec 2017 12:29:41 +1100 Subject: [PATCH] remove unneeded completion tests, add static definition test --- fixtures/completion/method_return_self.php | 11 -- .../completion/static_method_return_self.php | 12 -- tests/Server/TextDocument/CompletionTest.php | 184 ------------------ .../cases/staticMethodReturnType.php | 2 + .../staticMethodReturnType.php.expected.json | 25 +++ 5 files changed, 27 insertions(+), 207 deletions(-) delete mode 100644 fixtures/completion/method_return_self.php delete mode 100644 fixtures/completion/static_method_return_self.php diff --git a/fixtures/completion/method_return_self.php b/fixtures/completion/method_return_self.php deleted file mode 100644 index 9e6ef55..0000000 --- a/fixtures/completion/method_return_self.php +++ /dev/null @@ -1,11 +0,0 @@ -foo(); -$foo-> diff --git a/fixtures/completion/static_method_return_self.php b/fixtures/completion/static_method_return_self.php deleted file mode 100644 index bcc1264..0000000 --- a/fixtures/completion/static_method_return_self.php +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/tests/Server/TextDocument/CompletionTest.php b/tests/Server/TextDocument/CompletionTest.php index 112a259..424dc3c 100644 --- a/tests/Server/TextDocument/CompletionTest.php +++ b/tests/Server/TextDocument/CompletionTest.php @@ -554,146 +554,6 @@ class CompletionTest extends TestCase ], 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() { $completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/method_return_type.php'); @@ -716,28 +576,6 @@ class CompletionTest extends TestCase ], true), $items); } - public function testMethodReturnSelf() - { - $completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/method_return_self.php'); - $this->loader->open($completionUri, file_get_contents($completionUri)); - $items = $this->textDocument->completion( - new TextDocumentIdentifier($completionUri), - new Position(10, 6) - )->wait(); - $this->assertCompletionsListSubset(new CompletionList([ - new CompletionItem( - 'foo', - CompletionItemKind::METHOD, - '\FooClass', - null, - null, - null, - null, - null - ) - ], true), $items); - } - public function testStaticMethodReturnType() { $completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/static_method_return_type.php'); @@ -760,28 +598,6 @@ class CompletionTest extends TestCase ], true), $items); } - public function testStaticMethodReturnSelf() - { - $completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/static_method_return_self.php'); - $this->loader->open($completionUri, file_get_contents($completionUri)); - $items = $this->textDocument->completion( - new TextDocumentIdentifier($completionUri), - new Position(11, 6) - )->wait(); - $this->assertCompletionsListSubset(new CompletionList([ - new CompletionItem( - 'bar', - CompletionItemKind::METHOD, - 'mixed', - null, - null, - null, - null, - null - ) - ], true), $items); - } - private function assertCompletionsListSubset(CompletionList $subsetList, CompletionList $list) { foreach ($subsetList->items as $expectedItem) { diff --git a/tests/Validation/cases/staticMethodReturnType.php b/tests/Validation/cases/staticMethodReturnType.php index 325738a..0ce2654 100644 --- a/tests/Validation/cases/staticMethodReturnType.php +++ b/tests/Validation/cases/staticMethodReturnType.php @@ -5,5 +5,7 @@ class FooClass { return new FooClass(); } + public static function staticSelf(): self { } + public function bar() { } } diff --git a/tests/Validation/cases/staticMethodReturnType.php.expected.json b/tests/Validation/cases/staticMethodReturnType.php.expected.json index 8de5673..041042a 100644 --- a/tests/Validation/cases/staticMethodReturnType.php.expected.json +++ b/tests/Validation/cases/staticMethodReturnType.php.expected.json @@ -50,6 +50,31 @@ "parameters": [] } }, + "FooClass::staticSelf()": { + "fqn": "FooClass::staticSelf()", + "extends": [], + "isMember": true, + "roamed": false, + "isStatic": true, + "canBeInstantiated": false, + "symbolInformation": { + "name": "staticSelf", + "kind": 6, + "location": { + "uri": "./staticMethodReturnType.php" + }, + "containerName": "FooClass" + }, + "type__tostring": "\\FooClass", + "type": {}, + "declarationLine": "public static function staticSelf(): self { }", + "documentation": null, + "signatureInformation": { + "label": "()", + "documentation": null, + "parameters": [] + } + }, "FooClass->bar()": { "fqn": "FooClass->bar()", "extends": [],