diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-22 12:14:23 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-22 12:14:23 +0200 |
commit | 19910df42e93ef370048e8d0d2609af71bf46676 (patch) | |
tree | 2a9557b219a6f3d8efb830333900473a93241b19 /tests/unit/articleenhancer/GlobalArticleEnhancerTest.php | |
parent | fa73d339df403506d58104ee60575972b88bfc09 (diff) |
fix #454, allow global enhancers
Diffstat (limited to 'tests/unit/articleenhancer/GlobalArticleEnhancerTest.php')
-rw-r--r-- | tests/unit/articleenhancer/GlobalArticleEnhancerTest.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php b/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php new file mode 100644 index 000000000..4b0db31a1 --- /dev/null +++ b/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php @@ -0,0 +1,49 @@ +<?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 GlobalArticleEnhancerTest extends \PHPUnit_Framework_TestCase { + + private $enhancer; + + protected function setUp() { + $this->enhancer = new GlobalArticleEnhancer(); + } + + + public function testNoReplaceYoutubeAutoplay() { + $body = '<iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?autoplay=0" frameborder="0" allowfullscreen=""></iframe>'; + $expected = '<iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?autoplay=0" frameborder="0" allowfullscreen=""></iframe>'; + $item = new Item(); + $item->setBody($body); + + $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 = '<p>test <iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?tst=1&autoplay=0&abc=1" frameborder="0" allowfullscreen=""></iframe></p>'; + $item = new Item(); + $item->setBody($body); + + $result = $this->enhancer->enhance($item); + $this->assertEquals($expected, $result->getBody()); + } + +} |