diff options
-rw-r--r-- | core/Menu/MenuAbstract.php | 16 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/core/Menu/MenuAbstract.php b/core/Menu/MenuAbstract.php index 1c8e7f9800..7651a1199d 100644 --- a/core/Menu/MenuAbstract.php +++ b/core/Menu/MenuAbstract.php @@ -55,9 +55,9 @@ abstract class MenuAbstract extends Singleton */ protected function getAllMenus() { -// if (!empty(self::$menus)) { -// return self::$menus; -// } + if (!empty(self::$menus)) { + return self::$menus; + } self::$menus = PluginManager::getInstance()->findComponents('Menu', 'Piwik\\Plugin\\Menu'); @@ -65,6 +65,16 @@ abstract class MenuAbstract extends Singleton } /** + * To use only for tests. + * + * @deprecated The whole $menus cache should be replaced by a real transient cache + */ + public static function clearMenus() + { + self::$menus = array(); + } + + /** * Adds a new entry to the menu. * * @param string $menuName The menu's category name. Can be a translation token. diff --git a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php index a523deda05..f931366ea5 100644 --- a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php @@ -11,6 +11,7 @@ namespace Piwik\Tests\Framework\TestCase; use Piwik\Access; use Piwik\Config; use Piwik\Db; +use Piwik\Menu\MenuAbstract; use Piwik\Tests\Framework\Fixture; use Piwik\Cache as PiwikCache; use Piwik\Tests\Framework\TestingEnvironmentVariables; @@ -88,6 +89,7 @@ abstract class IntegrationTestCase extends SystemTestCase PiwikCache::getEagerCache()->flushAll(); PiwikCache::getTransientCache()->flushAll(); + MenuAbstract::clearMenus(); } /** |