summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-11-24 17:26:07 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2014-11-25 11:53:28 +0100
commitd4f107d4dd11d11c52f419d2f33abc5dc4a93573 (patch)
treec78445acdcfe38f30c0733162d09ffe07c03e2ea /tests/lib
parentc503ecd54495167f97b6602e5b41c1cf95467395 (diff)
downloadnextcloud-server-d4f107d4dd11d11c52f419d2f33abc5dc4a93573.tar.gz
nextcloud-server-d4f107d4dd11d11c52f419d2f33abc5dc4a93573.zip
simplify xml parser code
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/app/infoparser.php25
1 files changed, 8 insertions, 17 deletions
diff --git a/tests/lib/app/infoparser.php b/tests/lib/app/infoparser.php
index d1b2313e881..e416202a308 100644
--- a/tests/lib/app/infoparser.php
+++ b/tests/lib/app/infoparser.php
@@ -19,39 +19,30 @@ class InfoParser extends \PHPUnit_Framework_TestCase {
private $parser;
public function setUp() {
+ $config = $this->getMockBuilder('\OC\AllConfig')
+ ->disableOriginalConstructor()->getMock();
$httpHelper = $this->getMockBuilder('\OC\HTTPHelper')
- ->disableOriginalConstructor()
+ ->setConstructorArgs(array($config))
+ ->setMethods(array('getHeaders'))
->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())
+ $urlGenerator->expects($this->any())
->method('linkToDocs')
->will($this->returnCallback(function ($url) {
- return $url;
+ return "https://docs.example.com/server/go.php?to=$url";
}));
$this->parser = new \OC\App\InfoParser($httpHelper, $urlGenerator);
}
public function testParsingValidXml() {
+ $expectedData = json_decode(file_get_contents(OC::$SERVERROOT.'/tests/data/app/expected-info.json'), true);
$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.");
- }
+ $this->assertEquals($expectedData, $data);
}
}