build jpfop-0.17.0 build-local.properties nt='cgit v1.2.3'/>
summaryrefslogtreecommitdiffstats
path: root/tests/lib/app/infoparser.php
blob: d1b2313e881684be9cb1d279761d43f3b13e07ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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.");
		}
	}
}