diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-10-07 21:15:52 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-10-07 21:29:23 +0200 |
commit | 0c2b17c80f54027aaebbc43b8efb21fdaffe8d45 (patch) | |
tree | b3708ab19ca04336268ffb558c9000c9a7874700 /tests/lib/App | |
parent | 67d3574bdfdc08ad5815b5034a7c2c2e35afb4c0 (diff) | |
download | nextcloud-server-0c2b17c80f54027aaebbc43b8efb21fdaffe8d45.tar.gz nextcloud-server-0c2b17c80f54027aaebbc43b8efb21fdaffe8d45.zip |
Cache AppInfo in Memory Cache if configured
This saves around 20ms on a bare-bone instance, on bigger ones more (depending on the number of installed apps).
See https://blackfire.io/profiles/compare/fc326ad3-100d-49b8-8ea9-8343240f53f3/graph
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'tests/lib/App')
-rw-r--r-- | tests/lib/App/InfoParserTest.php | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/tests/lib/App/InfoParserTest.php b/tests/lib/App/InfoParserTest.php index af2dfd2ef1c..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 @@ -14,31 +13,46 @@ use OC\App\InfoParser; use Test\TestCase; class InfoParserTest extends TestCase { + /** @var OC\Cache\CappedMemoryCache */ + private static $cache; - /** @var InfoParser */ - private $parser; - - public function setUp() { - $this->parser = new InfoParser(); + public static function setUpBeforeClass() { + self::$cache = new OC\Cache\CappedMemoryCache(); } - /** - * @dataProvider providesInfoXml - */ - public function testParsingValidXml($expectedJson, $xmlFile) { + + public function parserTest($expectedJson, $xmlFile, $cache = null) { + $parser = new InfoParser($cache); + $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'), ); } } |