summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2013-09-27 20:03:00 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2013-09-27 20:03:16 +0200
commitd6066c382083dedf426abbfd5f2f1df725c68aaf (patch)
tree4406388c5a827ebe8ed62234e11e49c35e16f3a5 /tests
parent30080c220a3f5013875d6a52e4dfe634719cbeca (diff)
use seperate direcotires for article enhancers and fetchers
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/articleenhancer/EnhancerTest.php (renamed from tests/unit/utility/articleenhancer/EnhancerTest.php)6
-rw-r--r--tests/unit/articleenhancer/RegexArticleEnhancerTest.php (renamed from tests/unit/utility/articleenhancer/RegexArticleEnhancerTest.php)4
-rw-r--r--tests/unit/articleenhancer/XPathArticleEnhancerTest.php (renamed from tests/unit/utility/articleenhancer/XPathArticleEnhancerTest.php)4
-rw-r--r--tests/unit/businesslayer/FeedBusinessLayerTest.php8
-rw-r--r--tests/unit/controller/TwitterFetcherTest.php77
-rw-r--r--tests/unit/fetcher/FeedFetcherTest.php (renamed from tests/unit/utility/FeedFetcherTest.php)6
-rw-r--r--tests/unit/fetcher/FetcherTest.php (renamed from tests/unit/utility/FetcherTest.php)12
7 files changed, 20 insertions, 97 deletions
diff --git a/tests/unit/utility/articleenhancer/EnhancerTest.php b/tests/unit/articleenhancer/EnhancerTest.php
index 769538740..84cbe2a7c 100644
--- a/tests/unit/utility/articleenhancer/EnhancerTest.php
+++ b/tests/unit/articleenhancer/EnhancerTest.php
@@ -23,11 +23,11 @@
*
*/
-namespace OCA\News\Utility\ArticleEnhancer;
+namespace OCA\News\ArticleEnhancer;
use \OCA\News\Db\Item;
-require_once(__DIR__ . "/../../../classloader.php");
+require_once(__DIR__ . "/../../classloader.php");
class EnhancerTest extends \OCA\AppFramework\Utility\TestUtility {
@@ -39,7 +39,7 @@ class EnhancerTest extends \OCA\AppFramework\Utility\TestUtility {
protected function setUp(){
$this->enhancer = new Enhancer();
$this->articleEnhancer = $this->getMockBuilder(
- '\OCA\News\Utility\ArticleEnhancer\ArticleEnhancer')
+ '\OCA\News\ArticleEnhancer\ArticleEnhancer')
->disableOriginalConstructor()
->getMock();
$this->enhancer->registerEnhancer('test.com', $this->articleEnhancer);
diff --git a/tests/unit/utility/articleenhancer/RegexArticleEnhancerTest.php b/tests/unit/articleenhancer/RegexArticleEnhancerTest.php
index f775eac91..2d985edf1 100644
--- a/tests/unit/utility/articleenhancer/RegexArticleEnhancerTest.php
+++ b/tests/unit/articleenhancer/RegexArticleEnhancerTest.php
@@ -23,11 +23,11 @@
*
*/
-namespace OCA\News\Utility\ArticleEnhancer;
+namespace OCA\News\ArticleEnhancer;
use \OCA\News\Db\Item;
-require_once(__DIR__ . "/../../../classloader.php");
+require_once(__DIR__ . "/../../classloader.php");
class RegexArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility {
diff --git a/tests/unit/utility/articleenhancer/XPathArticleEnhancerTest.php b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
index b9c902147..a0f8db388 100644
--- a/tests/unit/utility/articleenhancer/XPathArticleEnhancerTest.php
+++ b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
@@ -23,11 +23,11 @@
*
*/
-namespace OCA\News\Utility\ArticleEnhancer;
+namespace OCA\News\ArticleEnhancer;
use \OCA\News\Db\Item;
-require_once(__DIR__ . "/../../../classloader.php");
+require_once(__DIR__ . "/../../classloader.php");
class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility {
diff --git a/tests/unit/businesslayer/FeedBusinessLayerTest.php b/tests/unit/businesslayer/FeedBusinessLayerTest.php
index 550f37dcb..5e379525d 100644
--- a/tests/unit/businesslayer/FeedBusinessLayerTest.php
+++ b/tests/unit/businesslayer/FeedBusinessLayerTest.php
@@ -32,8 +32,8 @@ use \OCA\AppFramework\Db\DoesNotExistException;
use \OCA\News\Db\Feed;
use \OCA\News\Db\Item;
-use \OCA\News\Utility\Fetcher;
-use \OCA\News\Utility\FetcherException;
+use \OCA\News\Fetcher\Fetcher;
+use \OCA\News\Fetcher\FetcherException;
class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
@@ -63,13 +63,13 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$this->feedMapper = $this->getMockBuilder('\OCA\News\Db\FeedMapper')
->disableOriginalConstructor()
->getMock();
- $this->fetcher = $this->getMockBuilder('\OCA\News\Utility\Fetcher')
+ $this->fetcher = $this->getMockBuilder('\OCA\News\Fetcher\Fetcher')
->disableOriginalConstructor()
->getMock();
$this->itemMapper = $this->getMockBuilder('\OCA\News\Db\ItemMapper')
->disableOriginalConstructor()
->getMock();
- $this->enhancer = $this->getMockBuilder('\OCA\News\Utility\ArticleEnhancer\Enhancer')
+ $this->enhancer = $this->getMockBuilder('\OCA\News\ArticleEnhancer\Enhancer')
->disableOriginalConstructor()
->getMock();
$this->feedBusinessLayer = new FeedBusinessLayer($this->feedMapper,
diff --git a/tests/unit/controller/TwitterFetcherTest.php b/tests/unit/controller/TwitterFetcherTest.php
deleted file mode 100644
index 9bda485bd..000000000
--- a/tests/unit/controller/TwitterFetcherTest.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-/**
-* ownCloud - News
-*
-* @author Alessandro Cosentino
-* @author Bernhard Posselt
-* @copyright 2012 Alessandro Cosentino cosenal@gmail.com
-* @copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-namespace OCA\News\Utility;
-
-require_once(__DIR__ . "/../../classloader.php");
-
-
-class TwitterFetcherTest extends \OCA\AppFramework\Utility\TestUtility {
-
- private $fetcher;
- private $twitter;
-
- protected function setUp(){
- $this->fetcher = $this->getMockBuilder('\OCA\News\Utility\FeedFetcher')
- ->disableOriginalConstructor()
- ->getMock();
- $this->twitter = new TwitterFetcher($this->fetcher);
- }
-
-
- public function testCanHandle(){
- $urls = array(
- 'https://twitter.com/GeorgeTakei',
- 'https://www.twitter.com/GeorgeTakei',
- 'http://twitter.com/GeorgeTakei',
- 'http://www.twitter.com/GeorgeTakei',
- 'www.twitter.com/GeorgeTakei',
- 'twitter.com/GeorgeTakei'
- );
- foreach($urls as $url){
- $this->assertTrue($this->twitter->canHandle($url), $url);
- }
- }
-
-
- public function testCanHandleDoesNotUseApiUrls(){
- $url = 'https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=GeorgeTakei';
- $this->assertFalse($this->twitter->canHandle($url));
- }
-
-
- public function testFetch(){
- $inUrl = 'https://www.twitter.com/GeorgeTakei';
- $outUrl = 'https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=GeorgeTakei';
- $out = 'hi';
- $this->fetcher->expects($this->once())
- ->method('fetch')
- ->with($this->equalTo($outUrl))
- ->will($this->returnValue($out));
-
- $return = $this->twitter->fetch($inUrl);
- $this->assertEquals($out, $return);
- }
-} \ No newline at end of file
diff --git a/tests/unit/utility/FeedFetcherTest.php b/tests/unit/fetcher/FeedFetcherTest.php
index 3865bda9f..466bcc446 100644
--- a/tests/unit/utility/FeedFetcherTest.php
+++ b/tests/unit/fetcher/FeedFetcherTest.php
@@ -23,7 +23,7 @@
*
*/
-namespace OCA\News\Utility;
+namespace OCA\News\Fetcher;
use \OCA\News\Db\Item;
use \OCA\News\Db\Feed;
@@ -143,7 +143,7 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility {
$this->core->expects($this->once())
->method('set_cache_duration')
->with($this->equalTo($this->cacheDuration));
- $this->setExpectedException('\OCA\News\Utility\FetcherException');
+ $this->setExpectedException('\OCA\News\Fetcher\FetcherException');
$this->fetcher->fetch($this->url);
}
@@ -155,7 +155,7 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility {
$this->core->expects($this->once())
->method('get_items')
->will($this->throwException(new \Exception('oh noes!')));
- $this->setExpectedException('\OCA\News\Utility\FetcherException');
+ $this->setExpectedException('\OCA\News\Fetcher\FetcherException');
$this->fetcher->fetch($this->url);
}
diff --git a/tests/unit/utility/FetcherTest.php b/tests/unit/fetcher/FetcherTest.php
index 8a57c9193..41f33129c 100644
--- a/tests/unit/utility/FetcherTest.php
+++ b/tests/unit/fetcher/FetcherTest.php
@@ -23,7 +23,7 @@
*
*/
-namespace OCA\News\Utility;
+namespace OCA\News\Fetcher;
require_once(__DIR__ . "/../../classloader.php");
@@ -39,7 +39,7 @@ class FetcherTest extends \OCA\AppFramework\Utility\TestUtility {
public function testFetch(){
$url = 'hi';
- $mockFetcher = $this->getMockBuilder('\OCA\News\Utility\IFeedFetcher')
+ $mockFetcher = $this->getMockBuilder('\OCA\News\Fetcher\IFeedFetcher')
->disableOriginalConstructor()
->getMock();
$mockFetcher->expects($this->once())
@@ -54,14 +54,14 @@ class FetcherTest extends \OCA\AppFramework\Utility\TestUtility {
public function testMultipleFetchers(){
$url = 'hi';
- $mockFetcher = $this->getMockBuilder('\OCA\News\Utility\IFeedFetcher')
+ $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\Utility\IFeedFetcher')
+ $mockFetcher2 = $this->getMockBuilder('\OCA\News\Fetcher\IFeedFetcher')
->disableOriginalConstructor()
->getMock();
$mockFetcher2->expects($this->once())
@@ -79,7 +79,7 @@ class FetcherTest extends \OCA\AppFramework\Utility\TestUtility {
public function testMultipleFetchersOnlyOneShouldHandle(){
$url = 'hi';
$return = 'zeas';
- $mockFetcher = $this->getMockBuilder('\OCA\News\Utility\IFeedFetcher')
+ $mockFetcher = $this->getMockBuilder('\OCA\News\Fetcher\IFeedFetcher')
->disableOriginalConstructor()
->getMock();
$mockFetcher->expects($this->once())
@@ -90,7 +90,7 @@ class FetcherTest extends \OCA\AppFramework\Utility\TestUtility {
->method('fetch')
->with($this->equalTo($url))
->will($this->returnValue($return));
- $mockFetcher2 = $this->getMockBuilder('\OCA\News\Utility\IFeedFetcher')
+ $mockFetcher2 = $this->getMockBuilder('\OCA\News\Fetcher\IFeedFetcher')
->disableOriginalConstructor()
->getMock();
$mockFetcher2->expects($this->never())