зеркало из https://github.com/nextcloud/news.git
more code coverage
This commit is contained in:
Родитель
b32fc30d68
Коммит
13b13aeda1
|
@ -47,7 +47,7 @@ class Fetcher {
|
|||
}
|
||||
}
|
||||
|
||||
return [null, []];
|
||||
return [null, []];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
|
||||
public function testFromImport() {
|
||||
private function createImportItem($isRead) {
|
||||
$item = new Item();
|
||||
$item->setGuid('guid');
|
||||
$item->setUrl('https://google');
|
||||
|
@ -173,9 +173,21 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
|
|||
$item->setBody('body');
|
||||
$item->setEnclosureMime('audio/ogg');
|
||||
$item->setEnclosureLink('enclink');
|
||||
$item->setUnread();
|
||||
$item->setStarred();
|
||||
|
||||
if ($isRead) {
|
||||
$item->setUnread();
|
||||
} else {
|
||||
$item->setRead();
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
|
||||
public function testFromImport() {
|
||||
$item = $this->createImportItem(false);
|
||||
|
||||
$import = [
|
||||
'guid' => $item->getGuid(),
|
||||
'url' => $item->getUrl(),
|
||||
|
@ -194,18 +206,9 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
|
|||
$this->assertEquals($item, $compareWith);
|
||||
}
|
||||
|
||||
|
||||
public function testFromImportRead() {
|
||||
$item = new Item();
|
||||
$item->setGuid('guid');
|
||||
$item->setUrl('https://google');
|
||||
$item->setTitle('title');
|
||||
$item->setAuthor('author');
|
||||
$item->setPubDate(123);
|
||||
$item->setBody('body');
|
||||
$item->setEnclosureMime('audio/ogg');
|
||||
$item->setEnclosureLink('enclink');
|
||||
$item->setRead();
|
||||
$item->setStarred();
|
||||
$item = $this->createImportItem(true);
|
||||
|
||||
$import = [
|
||||
'guid' => $item->getGuid(),
|
||||
|
|
|
@ -50,6 +50,30 @@ class FetcherTest extends \PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
|
||||
public function testNoFetchers(){
|
||||
$url = 'hi';
|
||||
$mockFetcher = $this->getMockBuilder('\OCA\News\Fetcher\IFeedFetcher')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mockFetcher->expects($this->once())
|
||||
->method('canHandle')
|
||||
->with($this->equalTo($url))
|
||||
->will($this->returnValue(false));
|
||||
$mockFetcher2 = $this->getMockBuilder('\OCA\News\Fetcher\IFeedFetcher')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mockFetcher2->expects($this->once())
|
||||
->method('canHandle')
|
||||
->with($this->equalTo($url))
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->fetcher->registerFetcher($mockFetcher);
|
||||
$this->fetcher->registerFetcher($mockFetcher2);
|
||||
|
||||
$result = $this->fetcher->fetch($url);
|
||||
$this->assertEquals([null, []], $result);
|
||||
}
|
||||
|
||||
public function testMultipleFetchers(){
|
||||
$url = 'hi';
|
||||
$mockFetcher = $this->getMockBuilder('\OCA\News\Fetcher\IFeedFetcher')
|
||||
|
|
|
@ -243,7 +243,7 @@ class ItemServiceTest extends \PHPUnit_Framework_TestCase {
|
|||
$this->assertTrue($item->isUnstarred());
|
||||
}
|
||||
|
||||
public function testRead(){
|
||||
public function testUnread(){
|
||||
$itemId = 3;
|
||||
$item = new Item();
|
||||
$item->setStatus(128);
|
||||
|
@ -271,6 +271,34 @@ class ItemServiceTest extends \PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
|
||||
public function testRead(){
|
||||
$itemId = 3;
|
||||
$item = new Item();
|
||||
$item->setStatus(128);
|
||||
$item->setId($itemId);
|
||||
$item->setUnread();
|
||||
|
||||
$expectedItem = new Item();
|
||||
$expectedItem->setStatus(128);
|
||||
$expectedItem->setRead();
|
||||
$expectedItem->setId($itemId);
|
||||
$expectedItem->setLastModified($this->time);
|
||||
|
||||
$this->mapper->expects($this->once())
|
||||
->method('find')
|
||||
->with($this->equalTo($itemId), $this->equalTo($this->user))
|
||||
->will($this->returnValue($item));
|
||||
|
||||
$this->mapper->expects($this->once())
|
||||
->method('update')
|
||||
->with($this->equalTo($expectedItem));
|
||||
|
||||
$this->itemService->read($itemId, true, $this->user);
|
||||
|
||||
$this->assertTrue($item->isRead());
|
||||
}
|
||||
|
||||
|
||||
public function testStarDoesNotExist(){
|
||||
|
||||
$this->setExpectedException('\OCA\News\Service\ServiceNotFoundException');
|
||||
|
|
|
@ -184,13 +184,21 @@ class ConfigTest extends \PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
|
||||
public function testMinimumAutoPurgeInterval() {
|
||||
$this->config->setAutoPurgeMinimumInterval(30);
|
||||
public function testNoLowMinimumAutoPurgeInterval() {
|
||||
$this->config->setAutoPurgeMinimumInterval(59);
|
||||
$interval = $this->config->getAutoPurgeMinimumInterval();
|
||||
|
||||
$this->assertSame(60, $interval);
|
||||
}
|
||||
|
||||
|
||||
public function testMinimumAutoPurgeInterval() {
|
||||
$this->config->setAutoPurgeMinimumInterval(61);
|
||||
$interval = $this->config->getAutoPurgeMinimumInterval();
|
||||
|
||||
$this->assertSame(61, $interval);
|
||||
}
|
||||
|
||||
public function testCacheDuration() {
|
||||
$this->config->setSimplePieCacheDuration(21);
|
||||
$duration = $this->config->getSimplePieCacheDuration();
|
||||
|
|
Загрузка…
Ссылка в новой задаче