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

HyperlinkTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 74
Duplicated Lines 50 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 37
loc 74
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetUrl() 0 9 1
A testSetUrl() 12 12 1
A testGetTooltip() 0 9 1
A testSetTooltip() 12 12 1
A testIsInternal() 13 13 1
A testGetHashCode() 0 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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