Skip to content
Extraits de code Groupes Projets
Valider ba2f86b2 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Use test.php DI config options if PIWIK_TEST_MODE is defined.

parent bd7b1634
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -13,7 +13,6 @@ use DI\ContainerBuilder;
use Doctrine\Common\Cache\ArrayCache;
use Piwik\Application\Kernel\GlobalSettingsProvider;
use Piwik\Application\Kernel\PluginList;
use Piwik\Development;
use Piwik\Plugin\Manager;
/**
......@@ -89,7 +88,12 @@ class ContainerFactory
}
// Environment config
$this->addEnvironmentConfig($builder);
$this->addEnvironmentConfig($builder, $this->environment);
// Test config
if (defined('PIWIK_TEST_MODE')) {
$this->addEnvironmentConfig($builder, 'test');
}
if (!empty($this->definitions)) {
$builder->addDefinitions($this->definitions);
......@@ -102,13 +106,13 @@ class ContainerFactory
return $container;
}
private function addEnvironmentConfig(ContainerBuilder $builder)
private function addEnvironmentConfig(ContainerBuilder $builder, $environment)
{
if (!$this->environment) {
if (!$environment) {
return;
}
$file = sprintf('%s/config/environment/%s.php', PIWIK_USER_PATH, $this->environment);
$file = sprintf('%s/config/environment/%s.php', PIWIK_USER_PATH, $environment);
if (file_exists($file)) {
$builder->addDefinitions($file);
......
......@@ -33,6 +33,8 @@ if (!Common::isPhpCliMode()) {
$testmode = in_array('--testmode', $_SERVER['argv']);
if ($testmode) {
define('PIWIK_TEST_MODE', true);
Tests\Framework\TestingEnvironment::addHooks();
}
......
......@@ -88,6 +88,10 @@ class TestsSetupFixture extends ConsoleCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!defined('PIWIK_TEST_MODE')) {
define('PIWIK_TEST_MODE', true);
}
$serverGlobal = $input->getOption('server-global');
if ($serverGlobal) {
$_SERVER = json_decode($serverGlobal, true);
......
......@@ -913,7 +913,7 @@ class Fixture extends \PHPUnit_Framework_Assert
public function createEnvironmentInstance()
{
$this->piwikEnvironment = new Environment('test', array_merge($this->provideContainerConfig(), $this->extraDefinitions));
$this->piwikEnvironment = new Environment($environment = null, array_merge($this->provideContainerConfig(), $this->extraDefinitions));
$this->piwikEnvironment->init();
}
}
......@@ -39,7 +39,7 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase
// make sure the global container exists for the next test case that is executed (since logging can be done
// before a test sets up an environment)
$nextTestEnviornment = new Environment('test', array(), $postBootstrappedEvent = false);
$nextTestEnviornment = new Environment($environment = null, array(), $postBootstrappedEvent = false);
$nextTestEnviornment->init();
parent::tearDown();
......@@ -57,7 +57,7 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase
protected function initEnvironment()
{
$this->environment = new Environment('test', $this->provideContainerConfig(), $postBootstrappedEvent = false);
$this->environment = new Environment($environment = null, $this->provideContainerConfig(), $postBootstrappedEvent = false);
$this->environment->init();
}
}
......@@ -18,10 +18,6 @@ use Piwik\DbHelper;
use Piwik\Piwik;
use Piwik\Application\Environment;
if (!defined('PIWIK_TEST_MODE')) {
define('PIWIK_TEST_MODE', true);
}
class Piwik_MockAccess
{
private $access;
......
......@@ -43,7 +43,7 @@ if (getenv('PIWIK_USE_XHPROF') == 1) {
// setup container for tests
function setupRootContainer() {
$rootTestEnvironment = new \Piwik\Application\Environment('test');
$rootTestEnvironment = new \Piwik\Application\Environment(null);
$rootTestEnvironment->init();
}
......
......@@ -6,6 +6,9 @@ if (!defined('PIWIK_INCLUDE_PATH')) {
if (!defined('PIWIK_USER_PATH')) {
define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH);
}
if (!defined('PIWIK_TEST_MODE')) {
define('PIWIK_TEST_MODE', true);
}
require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php';
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter