From a153d71266dd60945a7fec98777cddabcdbb6a9c Mon Sep 17 00:00:00 2001 From: Philip Nelson Date: Mon, 11 Dec 2017 20:03:40 +1100 Subject: [PATCH] revert return_type test and add specific return_self test --- .../completion/static_method_return_self.php | 12 ++++++++++ .../completion/static_method_return_type.php | 4 ++-- tests/Server/TextDocument/CompletionTest.php | 22 +++++++++++++++++++ .../WithReturnTypehints.php.expected.json | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 fixtures/completion/static_method_return_self.php diff --git a/fixtures/completion/static_method_return_self.php b/fixtures/completion/static_method_return_self.php new file mode 100644 index 0000000..bcc1264 --- /dev/null +++ b/fixtures/completion/static_method_return_self.php @@ -0,0 +1,12 @@ + diff --git a/fixtures/completion/static_method_return_type.php b/fixtures/completion/static_method_return_type.php index bcc1264..06cafdd 100644 --- a/fixtures/completion/static_method_return_type.php +++ b/fixtures/completion/static_method_return_type.php @@ -1,7 +1,7 @@ +$foo-> \ No newline at end of file diff --git a/tests/Server/TextDocument/CompletionTest.php b/tests/Server/TextDocument/CompletionTest.php index ac6f330..021fde0 100644 --- a/tests/Server/TextDocument/CompletionTest.php +++ b/tests/Server/TextDocument/CompletionTest.php @@ -620,6 +620,28 @@ 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/WithReturnTypehints.php.expected.json b/tests/Validation/cases/WithReturnTypehints.php.expected.json index 8c6b092..3d0861d 100644 --- a/tests/Validation/cases/WithReturnTypehints.php.expected.json +++ b/tests/Validation/cases/WithReturnTypehints.php.expected.json @@ -69,7 +69,7 @@ }, "containerName": "Fixtures\\Prophecy\\WithReturnTypehints" }, - "type__tostring": "\\self", + "type__tostring": "\\Fixtures\\Prophecy\\WithReturnTypehints", "type": {}, "declarationLine": "public function getSelf(): self {", "documentation": null