2012-08-03 20:21:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
class HyperlinkTest extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
if (!defined('PHPEXCEL_ROOT'))
|
|
|
|
{
|
|
|
|
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
|
|
|
|
}
|
|
|
|
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testGetUrl()
|
|
|
|
{
|
|
|
|
$urlValue = 'http://www.phpexcel.net';
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$testInstance = new PHPExcel_Cell_Hyperlink($urlValue);
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$result = $testInstance->getUrl();
|
|
|
|
$this->assertEquals($urlValue,$result);
|
|
|
|
}
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testSetUrl()
|
|
|
|
{
|
|
|
|
$initialUrlValue = 'http://www.phpexcel.net';
|
|
|
|
$newUrlValue = 'http://github.com/PHPOffice/PHPExcel';
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue);
|
|
|
|
$result = $testInstance->setUrl($newUrlValue);
|
|
|
|
$this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink);
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$result = $testInstance->getUrl();
|
|
|
|
$this->assertEquals($newUrlValue,$result);
|
|
|
|
}
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testGetTooltip()
|
|
|
|
{
|
|
|
|
$tooltipValue = 'PHPExcel Web Site';
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$testInstance = new PHPExcel_Cell_Hyperlink(null, $tooltipValue);
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$result = $testInstance->getTooltip();
|
|
|
|
$this->assertEquals($tooltipValue,$result);
|
|
|
|
}
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testSetTooltip()
|
|
|
|
{
|
|
|
|
$initialTooltipValue = 'PHPExcel Web Site';
|
|
|
|
$newTooltipValue = 'PHPExcel Repository on Github';
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$testInstance = new PHPExcel_Cell_Hyperlink(null, $initialTooltipValue);
|
|
|
|
$result = $testInstance->setTooltip($newTooltipValue);
|
|
|
|
$this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink);
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$result = $testInstance->getTooltip();
|
|
|
|
$this->assertEquals($newTooltipValue,$result);
|
|
|
|
}
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testIsInternal()
|
|
|
|
{
|
|
|
|
$initialUrlValue = 'http://www.phpexcel.net';
|
|
|
|
$newUrlValue = 'sheet://Worksheet1!A1';
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue);
|
|
|
|
$result = $testInstance->isInternal();
|
|
|
|
$this->assertFalse($result);
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$testInstance->setUrl($newUrlValue);
|
|
|
|
$result = $testInstance->isInternal();
|
|
|
|
$this->assertTrue($result);
|
|
|
|
}
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testGetHashCode()
|
|
|
|
{
|
|
|
|
$urlValue = 'http://www.phpexcel.net';
|
|
|
|
$tooltipValue = 'PHPExcel Web Site';
|
|
|
|
$initialExpectedHash = 'd84d713aed1dbbc8a7c5af183d6c7dbb';
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$testInstance = new PHPExcel_Cell_Hyperlink($urlValue, $tooltipValue);
|
2012-08-03 20:21:32 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
$result = $testInstance->getHashCode();
|
|
|
|
$this->assertEquals($initialExpectedHash,$result);
|
|
|
|
}
|
2012-08-03 20:21:32 +00:00
|
|
|
|
|
|
|
}
|