summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-10-21 16:45:36 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-10-21 16:45:36 +0200
commit42d69a95f3276a2d6089ca68f635c4e2f6aa7a23 (patch)
tree6a17fd7998f291e6dec1d996c1e7c724b92b8e58 /tests
parent0e6598b0734fb927109f745d9c0f3a8605a30ca5 (diff)
convert tabs indention to indention with 4 spaces because of mixing of both variants in code and better readability on github and websites because you cant set the indention width there and 8 spaces will be used for a tab
Diffstat (limited to 'tests')
-rw-r--r--tests/classloader.php26
-rw-r--r--tests/unit/articleenhancer/EnhancerTest.php150
-rw-r--r--tests/unit/articleenhancer/GlobalArticleEnhancerTest.php72
-rw-r--r--tests/unit/articleenhancer/RegexArticleEnhancerTest.php22
-rw-r--r--tests/unit/articleenhancer/XPathArticleEnhancerTest.php610
-rw-r--r--tests/unit/config/AppConfigTest.php340
-rw-r--r--tests/unit/config/ConfigTest.php350
-rw-r--r--tests/unit/controller/ExportControllerTest.php200
-rw-r--r--tests/unit/controller/FeedApiControllerTest.php576
-rw-r--r--tests/unit/controller/FeedControllerTest.php778
-rw-r--r--tests/unit/controller/FolderApiControllerTest.php332
-rw-r--r--tests/unit/controller/FolderControllerTest.php422
-rw-r--r--tests/unit/controller/ItemApiControllerTest.php674
-rw-r--r--tests/unit/controller/ItemControllerTest.php620
-rw-r--r--tests/unit/controller/PageControllerTest.php234
-rw-r--r--tests/unit/controller/UtilityApiControllerTest.php84
-rw-r--r--tests/unit/db/FeedMapperTest.php614
-rw-r--r--tests/unit/db/FeedTest.php142
-rw-r--r--tests/unit/db/FolderMapperTest.php238
-rw-r--r--tests/unit/db/FolderTest.php60
-rw-r--r--tests/unit/db/ItemMapperTest.php768
-rw-r--r--tests/unit/db/ItemTest.php514
-rw-r--r--tests/unit/db/MapperFactoryTest.php38
-rw-r--r--tests/unit/db/postgres/ItemMapperTest.php146
-rw-r--r--tests/unit/fetcher/FeedFetcherTest.php874
-rw-r--r--tests/unit/fetcher/FetcherTest.php194
-rw-r--r--tests/unit/http/TextDownloadResponseTest.php12
-rw-r--r--tests/unit/http/TextResponseTest.php30
-rw-r--r--tests/unit/service/FeedServiceTest.php1386
-rw-r--r--tests/unit/service/FolderServiceTest.php444
-rw-r--r--tests/unit/service/ItemServiceTest.php696
-rw-r--r--tests/unit/service/ServiceTest.php98
-rw-r--r--tests/unit/service/StatusFlagTest.php48
-rw-r--r--tests/unit/utility/FaviconFetcherTest.php256
-rw-r--r--tests/unit/utility/OPMLExporterTest.php172
-rw-r--r--tests/unit/utility/SimplePieAPIFactoryTest.php24
-rw-r--r--tests/unit/utility/UpdaterTest.php86
37 files changed, 6165 insertions, 6165 deletions
diff --git a/tests/classloader.php b/tests/classloader.php
index c7a8b9f4d..c660057df 100644
--- a/tests/classloader.php
+++ b/tests/classloader.php
@@ -18,20 +18,20 @@ require_once __DIR__ . '/../../../tests/lib/appframework/db/mappertestutility.ph
// to execute without owncloud, we need to create our own classloader
spl_autoload_register(function ($className){
- if (strpos($className, 'OCA\\') === 0) {
+ if (strpos($className, 'OCA\\') === 0) {
- $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
- $relPath = __DIR__ . '/../..' . $path;
+ $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
+ $relPath = __DIR__ . '/../..' . $path;
- if(file_exists($relPath)){
- require_once $relPath;
- }
- } else if(strpos($className, 'OCP\\') === 0) {
- $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
- $relPath = __DIR__ . '/../../../lib/public' . $path;
+ if(file_exists($relPath)){
+ require_once $relPath;
+ }
+ } else if(strpos($className, 'OCP\\') === 0) {
+ $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
+ $relPath = __DIR__ . '/../../../lib/public' . $path;
- if(file_exists($relPath)){
- require_once $relPath;
- }
- }
+ if(file_exists($relPath)){
+ require_once $relPath;
+ }
+ }
}); \ No newline at end of file
diff --git a/tests/unit/articleenhancer/EnhancerTest.php b/tests/unit/articleenhancer/EnhancerTest.php
index 49222a34d..d25b20dc7 100644
--- a/tests/unit/articleenhancer/EnhancerTest.php
+++ b/tests/unit/articleenhancer/EnhancerTest.php
@@ -17,85 +17,85 @@ use \OCA\News\Db\Item;
class AddEnhancer implements ArticleEnhancer {
- public function enhance(Item $item) {
- $body = $item->getBody();
- $item->setBody($body += 1);
- return $item;
- }
+ public function enhance(Item $item) {
+ $body = $item->getBody();
+ $item->setBody($body += 1);
+ return $item;
+ }
}
class EnhancerTest extends \PHPUnit_Framework_TestCase {
- private $enhancer;
- private $articleEnhancer;
- private $articleEnhancer2;
-
- protected function setUp(){
- $this->enhancer = new Enhancer();
- $this->articleEnhancer = $this->getMockBuilder(
- '\OCA\News\ArticleEnhancer\ArticleEnhancer')
- ->disableOriginalConstructor()
- ->getMock();
- $this->enhancer->registerEnhancer('test.com', $this->articleEnhancer);
- }
-
-
- public function testEnhanceSetsCorrectHash(){
- $item = new Item();
- $item->setUrl('hi');
- $urls = [
- 'https://test.com',
- 'https://www.test.com',
- 'https://test.com/',
- 'http://test.com',
- 'http://test.com/',
- 'http://www.test.com'
- ];
- for ($i=0; $i < count($urls); $i++) {
- $this->articleEnhancer->expects($this->at($i))
- ->method('enhance')
- ->with($this->equalTo($item))
- ->will($this->returnValue($item));
- }
-
- for ($i=0; $i < count($urls); $i++) {
- $url = $urls[$i];
- $result = $this->enhancer->enhance($item, $url);
- $this->assertEquals($item, $result);
- }
-
- }
-
-
- public function testNotMatchShouldJustReturnItem() {
- $item = new Item();
- $item->setUrl('hi');
-
- $url = 'https://tests.com';
- $this->articleEnhancer->expects($this->never())
- ->method('enhance');
-
- $result = $this->enhancer->enhance($item, $url);
- $this->assertEquals($item, $result);
- }
-
-
- public function testGlobalEnhancer() {
- $this->enhancer->registerGlobalEnhancer(
- new AddEnhancer()
- );
-
- $this->enhancer->registerGlobalEnhancer(
- new AddEnhancer()
- );
-
- $item = new Item();
- $item->setBody(1);
-
- $result = $this->enhancer->enhance($item, 'test');
-
- $this->assertEquals(3, $result->getBody());
- }
+ private $enhancer;
+ private $articleEnhancer;
+ private $articleEnhancer2;
+
+ protected function setUp(){
+ $this->enhancer = new Enhancer();
+ $this->articleEnhancer = $this->getMockBuilder(
+ '\OCA\News\ArticleEnhancer\ArticleEnhancer')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->enhancer->registerEnhancer('test.com', $this->articleEnhancer);
+ }
+
+
+ public function testEnhanceSetsCorrectHash(){
+ $item = new Item();
+ $item->setUrl('hi');
+ $urls = [
+ 'https://test.com',
+ 'https://www.test.com',
+ 'https://test.com/',
+ 'http://test.com',
+ 'http://test.com/',
+ 'http://www.test.com'
+ ];
+ for ($i=0; $i < count($urls); $i++) {
+ $this->articleEnhancer->expects($this->at($i))
+ ->method('enhance')
+ ->with($this->equalTo($item))
+ ->will($this->returnValue($item));
+ }
+
+ for ($i=0; $i < count($urls); $i++) {
+ $url = $urls[$i];
+ $result = $this->enhancer->enhance($item, $url);
+ $this->assertEquals($item, $result);
+ }
+
+ }
+
+
+ public function testNotMatchShouldJustReturnItem() {
+ $item = new Item();
+ $item->setUrl('hi');
+
+ $url = 'https://tests.com';
+ $this->articleEnhancer->expects($this->never())
+ ->method('enhance');
+
+ $result = $this->enhancer->enhance($item, $url);
+ $this->assertEquals($item, $result);
+ }
+
+
+ public function testGlobalEnhancer() {
+ $this->enhancer->registerGlobalEnhancer(
+ new AddEnhancer()
+ );
+
+ $this->enhancer->registerGlobalEnhancer(
+ new AddEnhancer()
+ );
+
+ $item = new Item();
+ $item->setBody(1);
+
+ $result = $this->enhancer->enhance($item, 'test');
+
+ $this->assertEquals(3, $result->getBody());
+ }
} \ No newline at end of file
diff --git a/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php b/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php
index 84c55ad9d..3add03eb5 100644
--- a/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php
+++ b/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php
@@ -18,54 +18,54 @@ use \OCA\News\Db\Item;
class GlobalArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
- private $enhancer;
+ private $enhancer;
- protected function setUp() {
- $this->enhancer = new GlobalArticleEnhancer();
- }
+ protected function setUp() {
+ $this->enhancer = new GlobalArticleEnhancer();
+ }
- public function testNoReplaceYoutubeAutoplay() {
- $body = '<iframe width="728" height="410" src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" frameborder="0" allowfullscreen=""></iframe>';
- $expected = '<div><iframe width="728" height="410" src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" frameborder="0" allowfullscreen=""></iframe></div>';
- $item = new Item();
- $item->setBody($body);
+ public function testNoReplaceYoutubeAutoplay() {
+ $body = '<iframe width="728" height="410" src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" frameborder="0" allowfullscreen=""></iframe>';
+ $expected = '<div><iframe width="728" height="410" src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" frameborder="0" allowfullscreen=""></iframe></div>';
+ $item = new Item();
+ $item->setBody($body);
- $result = $this->enhancer->enhance($item);
- $this->assertEquals($expected, $result->getBody());
- }
+ $result = $this->enhancer->enhance($item);
+ $this->assertEquals($expected, $result->getBody());
+ }
- public function testReplaceYoutubeAutoplay() {
- $body = 'test <iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?tst=1&autoplay=1&abc=1" frameborder="0" allowfullscreen=""></iframe>';
- $expected = '<div>test <iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?tst=1&amp;autoplay=0&amp;abc=1" frameborder="0" allowfullscreen=""></iframe></div>';
- $item = new Item();
- $item->setBody($body);
+ public function testReplaceYoutubeAutoplay() {
+ $body = 'test <iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?tst=1&autoplay=1&abc=1" frameborder="0" allowfullscreen=""></iframe>';
+ $expected = '<div>test <iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?tst=1&amp;autoplay=0&amp;abc=1" frameborder="0" allowfullscreen=""></iframe></div>';
+ $item = new Item();
+ $item->setBody($body);
- $result = $this->enhancer->enhance($item);
- $this->assertEquals($expected, $result->getBody());
- }
+ $result = $this->enhancer->enhance($item);
+ $this->assertEquals($expected, $result->getBody());
+ }
- public function testMultipleParagraphs() {
- $body = '<p>paragraph 1</p><p>paragraph 2</p>';
- $expected = '<div>' . $body . '</div>';
- $item = new Item();
- $item->setBody($body);
+ public function testMultipleParagraphs() {
+ $body = '<p>paragraph 1</p><p>paragraph 2</p>';
+ $expected = '<div>' . $body . '</div>';
+ $item = new Item();
+ $item->setBody($body);
- $result = $this->enhancer->enhance($item);
- $this->assertEquals($expected, $result->getBody());
- }
+ $result = $this->enhancer->enhance($item);
+ $this->assertEquals($expected, $result->getBody());
+ }
- public function testMultipleParagraphsInDiv() {
- $body = '<p>paragraph 1</p><p>paragraph 2</p>';
- $expected = '<div>' . $body . '</div>';
- $item = new Item();
- $item->setBody($body);
+ public function testMultipleParagraphsInDiv() {
+ $body = '<p>paragraph 1</p><p>paragraph 2</p>';
+ $expected = '<div>' . $body . '</div>';
+ $item = new Item();
+ $item->setBody($body);
- $result = $this->enhancer->enhance($item);
- $this->assertEquals($expected, $result->getBody());
- }
+ $result = $this->enhancer->enhance($item);
+ $this->assertEquals($expected, $result->getBody());
+ }
}
diff --git a/tests/unit/articleenhancer/RegexArticleEnhancerTest.php b/tests/unit/articleenhancer/RegexArticleEnhancerTest.php
index a08371f47..018a596fa 100644
--- a/tests/unit/articleenhancer/RegexArticleEnhancerTest.php
+++ b/tests/unit/articleenhancer/RegexArticleEnhancerTest.php
@@ -19,17 +19,17 @@ use \OCA\News\Db\Item;
class RegexArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
- public function testRegexEnhancer() {
- $item = new Item();
- $item->setBody('atests is a nice thing');
- $item->setUrl('http://john.com');
- $regex = ["%tes(ts)%" => "heho$1tests"];
-
- $regexEnhancer = new RegexArticleEnhancer('%john.com%', $regex);
- $item = $regexEnhancer->enhance($item);
-
- $this->assertEquals('ahehotstests is a nice thing', $item->getBody());
- }
+ public function testRegexEnhancer() {
+ $item = new Item();
+ $item->setBody('atests is a nice thing');
+ $item->setUrl('http://john.com');
+ $regex = ["%tes(ts)%" => "heho$1tests"];
+
+ $regexEnhancer = new RegexArticleEnhancer('%john.com%', $regex);
+ $item = $regexEnhancer->enhance($item);
+
+ $this->assertEquals('ahehotstests is a nice thing', $item->getBody());
+ }
} \ No newline at end of file
diff --git a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
index 082a2030c..0d4130e9e 100644
--- a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
+++ b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
@@ -18,310 +18,310 @@ use \OCA\News\Db\Item;
class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
- private $testEnhancer;
- private $fileFactory;
- private $timeout;
- private $redirects;
- private $headers;
- private $userAgent;
- private $proxyHost;
- private $proxyPort;
- private $proxyAuth;
-
- protected function setUp() {
- $this->timeout = 30;
- $this->fileFactory = $this->getMockBuilder('\OCA\News\Utility\SimplePieAPIFactory')
- ->disableOriginalConstructor()
- ->getMock();
- $this->proxyHost = 'test';
- $this->proxyPort = 3;
- $this->proxyAuth = 'hi';
- $this->config = $this->getMockBuilder(
- '\OCA\News\Config\Config')
- ->disableOriginalConstructor()
- ->getMock();
- $this->config->expects($this->any())
- ->method('getProxyHost')
- ->will($this->returnValue(''));
- $this->config->expects($this->any())
- ->method('getProxyAuth')
- ->will($this->returnValue($this->proxyAuth));
- $this->config->expects($this->any())
- ->method('getProxyPort')
- ->will($this->returnValue($this->proxyPort));
- $this->config->expects($this->any())
- ->method('getFeedFetcherTimeout')
- ->will($this->returnValue($this->timeout));
-
- $this->testEnhancer = new XPathArticleEnhancer(
- $this->fileFactory,
- [
- '/explosm.net\/comics/' => '//*[@id=\'maincontent\']/div[2]/div/span',
- '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div/div',
- '/explosm.net\/all/' => '//body/*',
- '/themerepublic.net/' => '//*[@class=\'post hentry\']'
- ],
- $this->config
- );
- $this->redirects = 5;
- $this->headers = null;
- $this->userAgent = 'Mozilla/5.0 AppleWebKit';
- }
-
-
- public function testXPathUsesNoProxy() {
- $file = new \stdClass;
- $file->headers = ["content-type"=>"text/html; charset=utf-8"];
- $file->body = '';
- $item = new Item();
- $item->setUrl('https://www.explosm.net/comics/312');
- $item->setBody('Hello thar');
-
- $this->fileFactory->expects($this->once())
- ->method('getFile')
- ->with($this->equalTo($item->getUrl()),
- $this->equalTo($this->timeout),
- $this->equalTo($this->redirects),
- $this->equalTo($this->headers),
- $this->equalTo($this->userAgent),
- $this->equalTo(false))
- ->will($this->returnValue($file));
-
- $result = $this->testEnhancer->enhance($item);
- $this->assertEquals('Hello thar', $result->getBody());
- }
-
-
- public function testDoesNotModifiyNotMatchingResults() {
- $item = new Item();
- $item->setUrl('http://explosm.net');
- $this->assertEquals($item, $this->testEnhancer->enhance($item));
- }
-
-
- public function testDoesModifiyArticlesThatMatch() {
- $file = new \stdClass;
- $file->headers = ["content-type"=>"text/html; charset=utf-8"];
- $file->body = '<html>
- <body>
- <div id="maincontent">
- <div>nooo</div>
- <div><div><span>hiho</span></div></div>
- </div>
- </body>
- </html>';
- $item = new Item();
- $item->setUrl('https://www.explosm.net/comics/312');
- $item->setBody('Hello thar');
-
- $this->fileFactory->expects($this->once())
- ->method('getFile')
- ->with($this->equalTo($item->getUrl()),
- $this->equalTo($this->timeout),
- $this->equalTo($this->redirects),
- $this->equalTo($this->headers),
- $this->equalTo($this->userAgent))
- ->will($this->returnValue($file));
-
- $result = $this->testEnhancer->enhance($item);
- $this->assertEquals('<div><span>hiho</span></div>', $result->getBody());
- }
-
-
- public function testDoesModifiyAllArticlesThatMatch() {
- $file = new \stdClass;
- $file->headers = ["content-type"=>"text/html; charset=utf-8"];
- $file->body = '<html>
- <body>
- <div id="maincontent">
- <div>nooo<div>hiho</div></div>
- <div><div>rawr</div></div