Add external links for tasks with plugin api
This commit is contained in:
57
tests/units/ExternalLink/WebLinkTest.php
Normal file
57
tests/units/ExternalLink/WebLinkTest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../Base.php';
|
||||
|
||||
use Kanboard\ExternalLink\WebLink;
|
||||
|
||||
class WebLinkTest extends Base
|
||||
{
|
||||
public function testGetTitleFromHtml()
|
||||
{
|
||||
$url = 'http://kanboard.net/something';
|
||||
$title = 'My title';
|
||||
$html = '<!DOCTYPE html><html><head><title> '.$title.' </title></head><body>Test</body></html>';
|
||||
|
||||
$this->container['httpClient'] = $this
|
||||
->getMockBuilder('\Kanboard\Core\Http\Client')
|
||||
->setConstructorArgs(array($this->container))
|
||||
->setMethods(array('get'))
|
||||
->getMock();
|
||||
|
||||
$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 = 'http://kanboard.net/something';
|
||||
$html = '<!DOCTYPE html><html><head></head><body>Test</body></html>';
|
||||
|
||||
$this->container['httpClient'] = $this
|
||||
->getMockBuilder('\Kanboard\Core\Http\Client')
|
||||
->setConstructorArgs(array($this->container))
|
||||
->setMethods(array('get'))
|
||||
->getMock();
|
||||
|
||||
$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.net/something', $webLink->getTitle());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user