Skip to content

Commit

Permalink
During tests, we shall load plugins that are in the .gitmodule file (…
Browse files Browse the repository at this point in the history
…official plugins found in marketplace),

as well as loading those that are in the global.ini.php (official plugins bundled in piwik).
  • Loading branch information
mattab committed Feb 20, 2014
1 parent 9742718 commit 53a6298
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
[submodule "plugins/TasksTimetable"]
path = plugins/TasksTimetable
url = https://github.com/piwik/plugin-TasksTimetable.git
branch = master
branch = master
[submodule "plugins/LoginHttpAuth"]
path = plugins/LoginHttpAuth
url = https://github.com/piwik/plugin-LoginHttpAuth.git
branch = master
branch = master
28 changes: 23 additions & 5 deletions core/Plugin/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use Piwik\Option;
use Piwik\Plugin;
use Piwik\Singleton;
use Piwik\Theme;
use Piwik\Translate;
use Piwik\Updater;
use Piwik\Theme;

require_once PIWIK_INCLUDE_PATH . '/core/EventDispatcher.php';

Expand Down Expand Up @@ -72,12 +72,17 @@ class Manager extends Singleton
'LeftMenu'
);

public static function getPluginsToLoadDuringTests()
public function getPluginsToLoadDuringTests()
{
$manager = \Piwik\Plugin\Manager::getInstance();
$toLoad = array();
foreach($manager->readPluginsDirectory() as $plugin) {
if($manager->isPluginBundledWithCore($plugin)) {
foreach($this->readPluginsDirectory() as $plugin) {
$isPluginBundledWithCore = $this->isPluginBundledWithCore($plugin);
$isPluginOfficiallySupported = $this->isPluginOfficialAndNotBundledWithCore($plugin);

// Do not enable other Login plugins
$isPluginOfficiallySupported = $isPluginOfficiallySupported && strpos($plugin, 'Login') === false;

if($isPluginBundledWithCore || $isPluginOfficiallySupported) {
$toLoad[] = $plugin;
}
}
Expand All @@ -92,6 +97,19 @@ public function getCorePluginsDisabledByDefault()
// If a plugin hooks onto at least an event starting with "Tracker.", we load the plugin during tracker
const TRACKER_EVENT_PREFIX = 'Tracker.';

/**
* @param $pluginName
* @return bool
*/
public function isPluginOfficialAndNotBundledWithCore($pluginName)
{
static $gitModules;
if(empty($gitModules)) {
$gitModules = file_get_contents(PIWIK_INCLUDE_PATH . '/.gitmodules');
}
return false !== strpos($gitModules, "plugins/" . $pluginName);
}

/**
* Update Plugins config
*
Expand Down
3 changes: 2 additions & 1 deletion core/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public static function isFileBasedSessions()
*/
public static function start($options = false)
{
if (self::$sessionStarted
if (headers_sent()
|| self::$sessionStarted
|| (defined('PIWIK_ENABLE_SESSION_START') && !PIWIK_ENABLE_SESSION_START)
) {
return;
Expand Down
5 changes: 4 additions & 1 deletion tests/PHPUnit/Core/ReleaseCheckListTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
use Piwik\Filesystem;
use Piwik\Plugin\Manager;
use Piwik\SettingsServer;

/**
Expand Down Expand Up @@ -192,7 +193,7 @@ public function test_DirectoriesInPluginsFolder_areKnown()
$manager = \Piwik\Plugin\Manager::getInstance();
$disabled = in_array($pluginName, $manager->getCorePluginsDisabledByDefault());

$isGitSubmodule = false !== strpos( file_get_contents(PIWIK_INCLUDE_PATH . '/.gitmodules'), "plugins/" . $pluginName);
$isGitSubmodule = Manager::getInstance()->isPluginOfficialAndNotBundledWithCore($pluginName);
$enabled = in_array($pluginName, $pluginsBundledWithPiwik) || $isGitSubmodule || $pluginName == $manager::DEFAULT_THEME;

$this->assertTrue( $enabled + $disabled === 1,
Expand Down Expand Up @@ -302,4 +303,6 @@ private function checkFilesAreInFormat($files, $format)
$this->fail("$format format failed for following icons $icons \n");
}
}


}

0 comments on commit 53a6298

Please sign in to comment.