diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-10-10 09:22:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-10 09:22:43 +0200 |
commit | 195fc041dabec4dc4d60ea1892d21d673e829b8b (patch) | |
tree | e82fd2291014675048330ae228d09a05e7f166dd /tests | |
parent | ce9e33bd3cdf179ffa276c67101934d82cb4c0e7 (diff) | |
parent | 0c2b17c80f54027aaebbc43b8efb21fdaffe8d45 (diff) | |
download | nextcloud-server-195fc041dabec4dc4d60ea1892d21d673e829b8b.tar.gz nextcloud-server-195fc041dabec4dc4d60ea1892d21d673e829b8b.zip |
Merge pull request #1663 from nextcloud/dont-reparse-info-xml
Dont reparse info xml + cache AppInfo XML
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/app/expected-info.json | 4 | ||||
-rw-r--r-- | tests/lib/App/CodeChecker/InfoCheckerTest.php | 4 | ||||
-rw-r--r-- | tests/lib/App/InfoParserTest.php | 47 |
3 files changed, 28 insertions, 27 deletions
diff --git a/tests/data/app/expected-info.json b/tests/data/app/expected-info.json index 6d8d85ab552..6ddd3ae8568 100644 --- a/tests/data/app/expected-info.json +++ b/tests/data/app/expected-info.json @@ -10,8 +10,8 @@ "requiremin": "4", "shipped": "true", "documentation": { - "user": "https://docs.example.com/server/go.php?to=user-encryption", - "admin": "https://docs.example.com/server/go.php?to=admin-encryption" + "user": "user-encryption", + "admin": "admin-encryption" }, "rememberlogin": "false", "types": ["filesystem"], diff --git a/tests/lib/App/CodeChecker/InfoCheckerTest.php b/tests/lib/App/CodeChecker/InfoCheckerTest.php index 1032e800be1..c16874fbd33 100644 --- a/tests/lib/App/CodeChecker/InfoCheckerTest.php +++ b/tests/lib/App/CodeChecker/InfoCheckerTest.php @@ -44,9 +44,7 @@ class InfoCheckerTest extends TestCase { protected function setUp() { parent::setUp(); - $infoParser = new InfoParser(\OC::$server->getURLGenerator()); - - $this->infoChecker = new InfoChecker($infoParser); + $this->infoChecker = new InfoChecker(new InfoParser()); } public function appInfoData() { diff --git a/tests/lib/App/InfoParserTest.php b/tests/lib/App/InfoParserTest.php index 7f52507bcf7..5a3847a71e8 100644 --- a/tests/lib/App/InfoParserTest.php +++ b/tests/lib/App/InfoParserTest.php @@ -1,5 +1,4 @@ <?php - /** * @author Thomas Müller * @copyright 2014 Thomas Müller deepdiver@owncloud.com @@ -10,46 +9,50 @@ namespace Test\App; use OC; -use OCP\IURLGenerator; +use OC\App\InfoParser; use Test\TestCase; class InfoParserTest extends TestCase { + /** @var OC\Cache\CappedMemoryCache */ + private static $cache; - /** @var \OC\App\InfoParser */ - private $parser; + public static function setUpBeforeClass() { + self::$cache = new OC\Cache\CappedMemoryCache(); + } - public function setUp() { - $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') - ->disableOriginalConstructor() - ->getMock(); - /** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject $urlGenerator */ - $urlGenerator->expects($this->any()) - ->method('linkToDocs') - ->will($this->returnCallback(function ($url) { - return "https://docs.example.com/server/go.php?to=$url"; - })); + public function parserTest($expectedJson, $xmlFile, $cache = null) { + $parser = new InfoParser($cache); - $this->parser = new \OC\App\InfoParser($urlGenerator); - } - - /** - * @dataProvider providesInfoXml - */ - public function testParsingValidXml($expectedJson, $xmlFile) { $expectedData = null; if (!is_null($expectedJson)) { $expectedData = json_decode(file_get_contents(OC::$SERVERROOT . "/tests/data/app/$expectedJson"), true); } - $data = $this->parser->parse(OC::$SERVERROOT. "/tests/data/app/$xmlFile"); + $data = $parser->parse(OC::$SERVERROOT. "/tests/data/app/$xmlFile"); $this->assertEquals($expectedData, $data); } + /** + * @dataProvider providesInfoXml + */ + public function testParsingValidXmlWithoutCache($expectedJson, $xmlFile) { + $this->parserTest($expectedJson, $xmlFile); + } + + /** + * @dataProvider providesInfoXml + */ + public function testParsingValidXmlWithCache($expectedJson, $xmlFile) { + $this->parserTest($expectedJson, $xmlFile, self::$cache); + } + function providesInfoXml() { return array( array('expected-info.json', 'valid-info.xml'), array(null, 'invalid-info.xml'), + array('expected-info.json', 'valid-info.xml'), + array(null, 'invalid-info.xml'), ); } } |