HyperlinkTest.php
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?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');
}
public function testGetUrl()
{
$urlValue = 'http://www.phpexcel.net';
$testInstance = new PHPExcel_Cell_Hyperlink($urlValue);
$result = $testInstance->getUrl();
$this->assertEquals($urlValue,$result);
}
public function testSetUrl()
{
$initialUrlValue = 'http://www.phpexcel.net';
$newUrlValue = 'http://github.com/PHPOffice/PHPExcel';
$testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue);
$result = $testInstance->setUrl($newUrlValue);
$this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink);
$result = $testInstance->getUrl();
$this->assertEquals($newUrlValue,$result);
}
public function testGetTooltip()
{
$tooltipValue = 'PHPExcel Web Site';
$testInstance = new PHPExcel_Cell_Hyperlink(NULL, $tooltipValue);
$result = $testInstance->getTooltip();
$this->assertEquals($tooltipValue,$result);
}
public function testSetTooltip()
{
$initialTooltipValue = 'PHPExcel Web Site';
$newTooltipValue = 'PHPExcel Repository on Github';
$testInstance = new PHPExcel_Cell_Hyperlink(NULL, $initialTooltipValue);
$result = $testInstance->setTooltip($newTooltipValue);
$this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink);
$result = $testInstance->getTooltip();
$this->assertEquals($newTooltipValue,$result);
}
public function testIsInternal()
{
$initialUrlValue = 'http://www.phpexcel.net';
$newUrlValue = 'sheet://Worksheet1!A1';
$testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue);
$result = $testInstance->isInternal();
$this->assertFalse($result);
$testInstance->setUrl($newUrlValue);
$result = $testInstance->isInternal();
$this->assertTrue($result);
}
public function testGetHashCode()
{
$urlValue = 'http://www.phpexcel.net';
$tooltipValue = 'PHPExcel Web Site';
$initialExpectedHash = 'd84d713aed1dbbc8a7c5af183d6c7dbb';
$testInstance = new PHPExcel_Cell_Hyperlink($urlValue, $tooltipValue);
$result = $testInstance->getHashCode();
$this->assertEquals($initialExpectedHash,$result);
}
}