/
HyperlinkTest.php
51 lines (44 loc) · 1.61 KB
/
HyperlinkTest.php
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
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
use PHPUnit\Framework\TestCase;
class HyperlinkTest extends TestCase
{
/**
* @dataProvider providerHYPERLINK
*
* @param mixed $expectedResult
* @param null|string $linkUrl
* @param null|string $description
*/
public function testHYPERLINK($expectedResult, $linkUrl, $description): void
{
$hyperlink = new Hyperlink();
$cell = $this->getMockBuilder(Cell::class)
->onlyMethods(['getHyperlink'])
->disableOriginalConstructor()
->getMock();
$cell->method('getHyperlink')
->willReturn($hyperlink);
$result = LookupRef::HYPERLINK($linkUrl, $description, $cell);
if (!is_array($expectedResult)) {
self::assertSame($expectedResult, $result);
} else {
self::assertSame($expectedResult[1], $result);
self::assertSame($expectedResult[0], $hyperlink->getUrl());
self::assertSame($expectedResult[1], $hyperlink->getTooltip());
}
}
public function providerHYPERLINK(): array
{
return require 'tests/data/Calculation/LookupRef/HYPERLINK.php';
}
public function testHYPERLINKwithoutCell(): void
{
$result = LookupRef::HYPERLINK('https://phpspreadsheet.readthedocs.io/en/latest/', 'Read the Docs');
self::assertSame(Functions::REF(), $result);
}
}