diff options
Diffstat (limited to 'tests/unit/articleenhancer/EnhancerTest.php')
-rw-r--r-- | tests/unit/articleenhancer/EnhancerTest.php | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/tests/unit/articleenhancer/EnhancerTest.php b/tests/unit/articleenhancer/EnhancerTest.php deleted file mode 100644 index f7dc2246e..000000000 --- a/tests/unit/articleenhancer/EnhancerTest.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php -/** - * ownCloud - News - * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING file. - * - * @author Alessandro Cosentino <cosenal@gmail.com> - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 - */ - -namespace OCA\News\ArticleEnhancer; - -use \OCA\News\Db\Item; - - -class AddEnhancer implements ArticleEnhancer { - 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' - ]; - $count = count($urls); - for ($i=0; $i < $count; $i++) { - $this->articleEnhancer->expects($this->at($i)) - ->method('enhance') - ->with($this->equalTo($item)) - ->will($this->returnValue($item)); - } - - for ($i=0; $i < $count; $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 |