Completed
Push — develop ( 682b1b...fe73b2 )
by Adrien
20:00
created

HyperlinkTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Cell;
4
5
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
6
7
class HyperlinkTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testGetUrl()
10
    {
11
        $urlValue = 'http://www.phpexcel.net';
12
13
        $testInstance = new Hyperlink($urlValue);
14
15
        $result = $testInstance->getUrl();
16
        $this->assertEquals($urlValue, $result);
17
    }
18
19 View Code Duplication
    public function testSetUrl()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
    {
21
        $initialUrlValue = 'http://www.phpexcel.net';
22
        $newUrlValue = 'http://github.com/PHPOffice/PhpSpreadsheet';
23
24
        $testInstance = new Hyperlink($initialUrlValue);
25
        $result = $testInstance->setUrl($newUrlValue);
26
        $this->assertTrue($result instanceof Hyperlink);
27
28
        $result = $testInstance->getUrl();
29
        $this->assertEquals($newUrlValue, $result);
30
    }
31
32
    public function testGetTooltip()
33
    {
34
        $tooltipValue = 'PhpSpreadsheet Web Site';
35
36
        $testInstance = new Hyperlink(null, $tooltipValue);
37
38
        $result = $testInstance->getTooltip();
39
        $this->assertEquals($tooltipValue, $result);
40
    }
41
42 View Code Duplication
    public function testSetTooltip()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $initialTooltipValue = 'PhpSpreadsheet Web Site';
45
        $newTooltipValue = 'PhpSpreadsheet Repository on Github';
46
47
        $testInstance = new Hyperlink(null, $initialTooltipValue);
48
        $result = $testInstance->setTooltip($newTooltipValue);
49
        $this->assertTrue($result instanceof Hyperlink);
50
51
        $result = $testInstance->getTooltip();
52
        $this->assertEquals($newTooltipValue, $result);
53
    }
54
55 View Code Duplication
    public function testIsInternal()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
    {
57
        $initialUrlValue = 'http://www.phpexcel.net';
58
        $newUrlValue = 'sheet://Worksheet1!A1';
59
60
        $testInstance = new Hyperlink($initialUrlValue);
61
        $result = $testInstance->isInternal();
62
        $this->assertFalse($result);
63
64
        $testInstance->setUrl($newUrlValue);
65
        $result = $testInstance->isInternal();
66
        $this->assertTrue($result);
67
    }
68
69
    public function testGetHashCode()
70
    {
71
        $urlValue = 'http://www.phpexcel.net';
72
        $tooltipValue = 'PhpSpreadsheet Web Site';
73
        $initialExpectedHash = '6f1d4cbf40034b9ddc3fbf6019506e91';
74
75
        $testInstance = new Hyperlink($urlValue, $tooltipValue);
76
77
        $result = $testInstance->getHashCode();
78
        $this->assertEquals($initialExpectedHash, $result);
79
    }
80
}
81