blob: 0acad023622d793b04de0901025b8b781d51c14a (
plain)
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
|
<?php
require_once __DIR__.'/../Base.php';
use Kanboard\ExternalLink\WebLink;
class WebLinkTest extends Base
{
public function testGetTitleFromHtml()
{
$url = 'https://kanboard.org/something';
$title = 'My title';
$html = '<!DOCTYPE html><html><head><title> '.$title.' </title></head><body>Test</body></html>';
$webLink = new WebLink($this->container);
$webLink->setUrl($url);
$this->assertEquals($url, $webLink->getUrl());
$this->container['httpClient']
->expects($this->once())
->method('get')
->with($url)
->will($this->returnValue($html));
$this->assertEquals($title, $webLink->getTitle());
}
public function testGetTitleFromUrl()
{
$url = 'https://kanboard.org/something';
$html = '<!DOCTYPE html><html><head></head><body>Test</body></html>';
$webLink = new WebLink($this->container);
$webLink->setUrl($url);
$this->assertEquals($url, $webLink->getUrl());
$this->container['httpClient']
->expects($this->once())
->method('get')
->with($url)
->will($this->returnValue($html));
$this->assertEquals('kanboard.org/something', $webLink->getTitle());
}
}
|