summaryrefslogtreecommitdiffstats
path: root/tests/lib/app/infoparser.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/app/infoparser.php')
-rw-r--r--tests/lib/app/infoparser.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/lib/app/infoparser.php b/tests/lib/app/infoparser.php
new file mode 100644
index 00000000000..d1b2313e881
--- /dev/null
+++ b/tests/lib/app/infoparser.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * @author Thomas Müller
+ * @copyright 2014 Thomas Müller deepdiver@owncloud.com
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\App;
+
+use OC;
+
+class InfoParser extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var \OC\App\InfoParser
+ */
+ private $parser;
+
+ public function setUp() {
+ $httpHelper = $this->getMockBuilder('\OC\HTTPHelper')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $httpHelper->expects($this->any())
+ ->method('isHTTPURL')
+ ->will($this->returnCallback(function ($url) {
+ return stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0;
+ }));
+
+ $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ //linkToDocs
+ $httpHelper->expects($this->any())
+ ->method('linkToDocs')
+ ->will($this->returnCallback(function ($url) {
+ return $url;
+ }));
+
+ $this->parser = new \OC\App\InfoParser($httpHelper, $urlGenerator);
+ }
+
+ public function testParsingValidXml() {
+ $data = $this->parser->parse(OC::$SERVERROOT.'/tests/data/app/valid-info.xml');
+
+ $expectedKeys = array(
+ 'id', 'info', 'remote', 'public', 'name', 'description', 'licence', 'author', 'requiremin', 'shipped',
+ 'documentation', 'rememberlogin', 'types', 'ocsid'
+ );
+ foreach($expectedKeys as $expectedKey) {
+ $this->assertArrayHasKey($expectedKey, $data, "ExpectedKey($expectedKey) was missing.");
+ }
+ }
+}