| 
									
										
										
										
											2016-10-08 12:59:08 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | declare(strict_types = 1); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 23:45:15 +00:00
										 |  |  | namespace LanguageServer\Tests\Server\TextDocument\Definition; | 
					
						
							| 
									
										
										
										
											2016-10-08 12:59:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  | use LanguageServer\Protocol\{TextDocumentIdentifier, Location}; | 
					
						
							| 
									
										
										
										
											2016-10-11 23:45:15 +00:00
										 |  |  | use function LanguageServer\pathToUri; | 
					
						
							| 
									
										
										
										
											2016-10-08 12:59:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  | class NamespacedTest extends GlobalTest | 
					
						
							| 
									
										
										
										
											2016-10-08 12:59:08 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  |     public function getReferenceLocations(string $fqn): array | 
					
						
							| 
									
										
										
										
											2016-10-08 12:59:08 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  |         return parent::getReferenceLocations('TestNamespace\\' . $fqn); | 
					
						
							| 
									
										
										
										
											2016-10-12 10:40:13 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  |     public function getDefinitionLocation(string $fqn): Location | 
					
						
							| 
									
										
										
										
											2016-10-12 10:40:13 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  |         return parent::getDefinitionLocation('TestNamespace\\' . $fqn); | 
					
						
							| 
									
										
										
										
											2016-10-12 10:40:13 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  |     public function testDefinitionForConstants() | 
					
						
							| 
									
										
										
										
											2016-10-12 10:40:13 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  |         // echo TEST_CONST;
 | 
					
						
							|  |  |  |         // Get definition for TEST_CONST
 | 
					
						
							|  |  |  |         $reference = $this->getReferenceLocations('TEST_CONST')[0]; | 
					
						
							| 
									
										
										
										
											2016-11-14 09:25:44 +00:00
										 |  |  |         $result = $this->textDocument->definition( | 
					
						
							|  |  |  |             new TextDocumentIdentifier($reference->uri), | 
					
						
							|  |  |  |             $reference->range->start | 
					
						
							|  |  |  |         )->wait(); | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  |         $this->assertEquals($this->getDefinitionLocation('TEST_CONST'), $result); | 
					
						
							| 
									
										
										
										
											2016-10-12 10:40:13 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-08 12:59:08 +00:00
										 |  |  |     public function testDefinitionForClassLikeUseStatement() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // use TestNamespace\TestClass;
 | 
					
						
							|  |  |  |         // Get definition for TestClass
 | 
					
						
							| 
									
										
										
										
											2017-11-19 00:59:57 +00:00
										 |  |  |         $reference = $this->getReferenceLocations('TestClass')[7]; | 
					
						
							| 
									
										
										
										
											2016-11-14 09:25:44 +00:00
										 |  |  |         $result = $this->textDocument->definition( | 
					
						
							|  |  |  |             new TextDocumentIdentifier($reference->uri), | 
					
						
							|  |  |  |             $reference->range->start | 
					
						
							|  |  |  |         )->wait(); | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  |         $this->assertEquals($this->getDefinitionLocation('TestClass'), $result); | 
					
						
							| 
									
										
										
										
											2016-10-08 12:59:08 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function testDefinitionForClassLikeGroupUseStatement() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // use TestNamespace\{TestTrait, TestInterface};
 | 
					
						
							|  |  |  |         // Get definition for TestInterface
 | 
					
						
							| 
									
										
										
										
											2017-11-19 00:59:57 +00:00
										 |  |  |         $reference = $this->getReferenceLocations('TestClass')[1]; | 
					
						
							| 
									
										
										
										
											2016-11-14 09:25:44 +00:00
										 |  |  |         $result = $this->textDocument->definition( | 
					
						
							|  |  |  |             new TextDocumentIdentifier($reference->uri), | 
					
						
							|  |  |  |             $reference->range->start | 
					
						
							|  |  |  |         )->wait(); | 
					
						
							| 
									
										
										
										
											2016-10-18 08:48:16 +00:00
										 |  |  |         $this->assertEquals($this->getDefinitionLocation('TestClass'), $result); | 
					
						
							| 
									
										
										
										
											2016-10-08 12:59:08 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } |