| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-31 17:18:12 +00:00
										 |  |  | namespace PhpOffice\PhpSpreadsheetTests\Cell; | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-31 17:18:12 +00:00
										 |  |  | use PhpOffice\PhpSpreadsheet\Cell\Hyperlink; | 
					
						
							| 
									
										
										
										
											2017-11-08 15:48:01 +00:00
										 |  |  | use PHPUnit\Framework\TestCase; | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-08 15:48:01 +00:00
										 |  |  | class HyperlinkTest extends TestCase | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testGetUrl(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-30 10:07:22 +00:00
										 |  |  |         $urlValue = 'https://www.example.com'; | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $testInstance = new Hyperlink($urlValue); | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $result = $testInstance->getUrl(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($urlValue, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testSetUrl(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-30 10:07:22 +00:00
										 |  |  |         $initialUrlValue = 'https://www.example.com'; | 
					
						
							| 
									
										
										
										
											2016-08-16 14:24:47 +00:00
										 |  |  |         $newUrlValue = 'http://github.com/PHPOffice/PhpSpreadsheet'; | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $testInstance = new Hyperlink($initialUrlValue); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $result = $testInstance->setUrl($newUrlValue); | 
					
						
							| 
									
										
										
										
											2017-12-06 09:46:31 +00:00
										 |  |  |         self::assertInstanceOf(Hyperlink::class, $result); | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $result = $testInstance->getUrl(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($newUrlValue, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testGetTooltip(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-16 14:24:47 +00:00
										 |  |  |         $tooltipValue = 'PhpSpreadsheet Web Site'; | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $testInstance = new Hyperlink(null, $tooltipValue); | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $result = $testInstance->getTooltip(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($tooltipValue, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testSetTooltip(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-16 14:24:47 +00:00
										 |  |  |         $initialTooltipValue = 'PhpSpreadsheet Web Site'; | 
					
						
							|  |  |  |         $newTooltipValue = 'PhpSpreadsheet Repository on Github'; | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $testInstance = new Hyperlink(null, $initialTooltipValue); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $result = $testInstance->setTooltip($newTooltipValue); | 
					
						
							| 
									
										
										
										
											2017-12-06 09:46:31 +00:00
										 |  |  |         self::assertInstanceOf(Hyperlink::class, $result); | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $result = $testInstance->getTooltip(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($newTooltipValue, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsInternal(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-30 10:07:22 +00:00
										 |  |  |         $initialUrlValue = 'https://www.example.com'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $newUrlValue = 'sheet://Worksheet1!A1'; | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $testInstance = new Hyperlink($initialUrlValue); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $result = $testInstance->isInternal(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertFalse($result); | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $testInstance->setUrl($newUrlValue); | 
					
						
							|  |  |  |         $result = $testInstance->isInternal(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertTrue($result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testGetHashCode(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-30 10:07:22 +00:00
										 |  |  |         $urlValue = 'https://www.example.com'; | 
					
						
							| 
									
										
										
										
											2016-08-16 14:24:47 +00:00
										 |  |  |         $tooltipValue = 'PhpSpreadsheet Web Site'; | 
					
						
							| 
									
										
										
										
											2017-12-30 10:07:22 +00:00
										 |  |  |         $initialExpectedHash = '3a8d5a682dba27276dce538c39402437'; | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $testInstance = new Hyperlink($urlValue, $tooltipValue); | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $result = $testInstance->getHashCode(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($initialExpectedHash, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | } |