PhpSpreadsheet/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php

82 lines
2.4 KiB
PHP
Raw Permalink Normal View History

<?php
namespace PhpOffice\PhpSpreadsheetTests\Cell;
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
use PHPUnit\Framework\TestCase;
class HyperlinkTest extends TestCase
{
2020-05-18 04:49:57 +00:00
public function testGetUrl(): void
2015-05-17 13:00:02 +00:00
{
2017-12-30 10:07:22 +00:00
$urlValue = 'https://www.example.com';
$testInstance = new Hyperlink($urlValue);
2015-05-17 13:00:02 +00:00
$result = $testInstance->getUrl();
self::assertEquals($urlValue, $result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testSetUrl(): void
2015-05-17 13:00:02 +00:00
{
2017-12-30 10:07:22 +00:00
$initialUrlValue = 'https://www.example.com';
$newUrlValue = 'http://github.com/PHPOffice/PhpSpreadsheet';
$testInstance = new Hyperlink($initialUrlValue);
2015-05-17 13:00:02 +00:00
$result = $testInstance->setUrl($newUrlValue);
2017-12-06 09:46:31 +00:00
self::assertInstanceOf(Hyperlink::class, $result);
2015-05-17 13:00:02 +00:00
$result = $testInstance->getUrl();
self::assertEquals($newUrlValue, $result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testGetTooltip(): void
2015-05-17 13:00:02 +00:00
{
$tooltipValue = 'PhpSpreadsheet Web Site';
$testInstance = new Hyperlink(null, $tooltipValue);
2015-05-17 13:00:02 +00:00
$result = $testInstance->getTooltip();
self::assertEquals($tooltipValue, $result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testSetTooltip(): void
2015-05-17 13:00:02 +00:00
{
$initialTooltipValue = 'PhpSpreadsheet Web Site';
$newTooltipValue = 'PhpSpreadsheet Repository on Github';
$testInstance = new Hyperlink(null, $initialTooltipValue);
2015-05-17 13:00:02 +00:00
$result = $testInstance->setTooltip($newTooltipValue);
2017-12-06 09:46:31 +00:00
self::assertInstanceOf(Hyperlink::class, $result);
2015-05-17 13:00:02 +00:00
$result = $testInstance->getTooltip();
self::assertEquals($newTooltipValue, $result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testIsInternal(): void
2015-05-17 13:00:02 +00:00
{
2017-12-30 10:07:22 +00:00
$initialUrlValue = 'https://www.example.com';
2015-05-17 13:00:02 +00:00
$newUrlValue = 'sheet://Worksheet1!A1';
$testInstance = new Hyperlink($initialUrlValue);
2015-05-17 13:00:02 +00:00
$result = $testInstance->isInternal();
self::assertFalse($result);
2015-05-17 13:00:02 +00:00
$testInstance->setUrl($newUrlValue);
$result = $testInstance->isInternal();
self::assertTrue($result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testGetHashCode(): void
2015-05-17 13:00:02 +00:00
{
2017-12-30 10:07:22 +00:00
$urlValue = 'https://www.example.com';
$tooltipValue = 'PhpSpreadsheet Web Site';
2017-12-30 10:07:22 +00:00
$initialExpectedHash = '3a8d5a682dba27276dce538c39402437';
$testInstance = new Hyperlink($urlValue, $tooltipValue);
2015-05-17 13:00:02 +00:00
$result = $testInstance->getHashCode();
self::assertEquals($initialExpectedHash, $result);
2015-05-17 13:00:02 +00:00
}
}