From f46b434a122377596f7861a75fc50106ea514e8e Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Wed, 9 Sep 2015 18:37:33 +0300 Subject: [PATCH] Namespacing, reusing --- apps/files_versions/lib/storage.php | 9 +++++++-- apps/files_versions/tests/expiration.php | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php index 90fe308e970..ba2b78ff4d2 100644 --- a/apps/files_versions/lib/storage.php +++ b/apps/files_versions/lib/storage.php @@ -68,6 +68,9 @@ class Storage { //until the end one version per week 6 => array('intervalEndsAfter' => -1, 'step' => 604800), ); + + /** @var \OCA\Files_Versions\AppInfo\Application */ + private static $application; public static function getUidAndFilename($filename) { $uid = \OC\Files\Filesystem::getOwner($filename); @@ -709,8 +712,10 @@ class Storage { * @return Expiration */ protected static function getExpiration(){ - $application = new Application(); - return $application->getContainer()->query('Expiration'); + if (is_null(self::$application)) { + self::$application = new Application(); + } + return self::$application->getContainer()->query('Expiration'); } } diff --git a/apps/files_versions/tests/expiration.php b/apps/files_versions/tests/expiration.php index fd5e022f689..54024b85b78 100644 --- a/apps/files_versions/tests/expiration.php +++ b/apps/files_versions/tests/expiration.php @@ -19,9 +19,11 @@ * */ -namespace OCA\Files_Versions; +namespace OCA\Files_Versions\Tests; -class Expiration_Test extends \PHPUnit_Framework_TestCase { +use \OCA\Files_Versions\Expiration; + +class Expiration_Test extends \Test\TestCase { const SECONDS_PER_DAY = 86400; //60*60*24 public function expirationData(){