diff options
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()); + } + +} |