summaryrefslogtreecommitdiffstats
path: root/tests/unit/articleenhancer/EnhancerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/articleenhancer/EnhancerTest.php')
-rw-r--r--tests/unit/articleenhancer/EnhancerTest.php35
1 files changed, 30 insertions, 5 deletions
diff --git a/tests/unit/articleenhancer/EnhancerTest.php b/tests/unit/articleenhancer/EnhancerTest.php
index 129b88fd7..2223b1d06 100644
--- a/tests/unit/articleenhancer/EnhancerTest.php
+++ b/tests/unit/articleenhancer/EnhancerTest.php
@@ -16,6 +16,15 @@ 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;
@@ -43,19 +52,19 @@ class EnhancerTest extends \PHPUnit_Framework_TestCase {
'http://test.com/',
'http://www.test.com'
];
- for ($i=0; $i < count($urls); $i++) {
+ 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++) {
+ for ($i=0; $i < count($urls); $i++) {
$url = $urls[$i];
$result = $this->enhancer->enhance($item, $url);
$this->assertEquals($item, $result);
}
-
+
}
@@ -67,10 +76,26 @@ class EnhancerTest extends \PHPUnit_Framework_TestCase {
$this->articleEnhancer->expects($this->never())
->method('enhance');
- $result = $this->enhancer->enhance($item, $url);
+ $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, $item->getBody());
+ }
+
} \ No newline at end of file