diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-04 01:04:03 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-04 01:04:03 +0200 |
commit | 89de367fc8351e0738e39ca579eeb8f2bd1f8491 (patch) | |
tree | ad40aab4779210f5fcdb3f3f0f10f7493be0568b /tests/unit | |
parent | 9a5a0c5d6e8f9a8f4d309045e369804fb82525a6 (diff) |
also sanitize imported json
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/utility/ImportParserTest.php | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/unit/utility/ImportParserTest.php b/tests/unit/utility/ImportParserTest.php index 1a14479fd..04dc4ebc8 100644 --- a/tests/unit/utility/ImportParserTest.php +++ b/tests/unit/utility/ImportParserTest.php @@ -35,9 +35,11 @@ class ImportParserTest extends \OCA\AppFramework\Utility\TestUtility { private $parser; private $time; private $in; + private $purifier; protected function setUp(){ $this->time = 222; + $this->purifier = $this->getMock('purifier', array('purify')); $timeFactory = $this->getMockBuilder( '\OCA\AppFramework\Utility\TimeFactory') ->disableOriginalConstructor() @@ -46,7 +48,7 @@ class ImportParserTest extends \OCA\AppFramework\Utility\TestUtility { ->method('getTime') ->will($this->returnValue($this->time)); - $this->parser = new ImportParser($timeFactory); + $this->parser = new ImportParser($timeFactory, $this->purifier); $this->in = array( 'items' => array( array( @@ -74,12 +76,18 @@ class ImportParserTest extends \OCA\AppFramework\Utility\TestUtility { public function testParsesItems() { + $body = $this->in['items'][0]['summary']['content']; + $this->purifier->expects($this->once()) + ->method('purify') + ->with($this->equalTo($body)) + ->will($this->returnValue($body)); + $result = $this->parser->parse($this->in); $out = new Item(); $out->setTitle($this->in['items'][0]['title']); $out->setPubDate($this->in['items'][0]['published']); - $out->setBody($this->in['items'][0]['summary']['content']); + $out->setBody($body); $out->setUrl($this->in['items'][0]['alternate'][0]['href']); $out->setGuid($this->in['items'][0]['id']); $out->setGuidHash(md5($this->in['items'][0]['id'])); @@ -93,13 +101,20 @@ class ImportParserTest extends \OCA\AppFramework\Utility\TestUtility { public function testParsesItemsNoSummary() { $this->in['items'][0]['content']['content'] = 'hi'; + $body = $this->in['items'][0]['content']['content']; + + $this->purifier->expects($this->once()) + ->method('purify') + ->with($this->equalTo($body)) + ->will($this->returnValue($body)); + unset($this->in['items'][0]['summary']); $result = $this->parser->parse($this->in); $out = new Item(); $out->setTitle($this->in['items'][0]['title']); $out->setPubDate($this->in['items'][0]['published']); - $out->setBody($this->in['items'][0]['content']['content']); + $out->setBody($body); $out->setUrl($this->in['items'][0]['alternate'][0]['href']); $out->setGuid($this->in['items'][0]['id']); $out->setGuidHash(md5($this->in['items'][0]['id'])); @@ -129,13 +144,19 @@ class ImportParserTest extends \OCA\AppFramework\Utility\TestUtility { } public function testParsesItemsNoPubDate() { + $body = $this->in['items'][0]['summary']['content']; + $this->purifier->expects($this->once()) + ->method('purify') + ->with($this->equalTo($body)) + ->will($this->returnValue($body)); + unset($this->in['items'][0]['published']); $result = $this->parser->parse($this->in); $out = new Item(); $out->setTitle($this->in['items'][0]['title']); $out->setPubDate($this->time); - $out->setBody($this->in['items'][0]['summary']['content']); + $out->setBody($body); $out->setUrl($this->in['items'][0]['alternate'][0]['href']); $out->setGuid($this->in['items'][0]['id']); $out->setGuidHash(md5($this->in['items'][0]['id'])); |