clearAllViewDataTableParameters() public static method

Esempio n. 1
0
 public function test_clearAllViewDataTableParameters_shouldRemoveAllPersistedParameters()
 {
     ViewDataTableManager::saveViewDataTableParameters('mylogin1', 'API.get1', array('flat' => 1));
     ViewDataTableManager::saveViewDataTableParameters('mylogin1', 'API.get2', array('flat' => 1));
     ViewDataTableManager::saveViewDataTableParameters('mylogin2', 'API.get3', array('flat' => 1));
     ViewDataTableManager::saveViewDataTableParameters('mylogin1', 'API.get4', array('flat' => 1));
     ViewDataTableManager::saveViewDataTableParameters('mylogin3', 'API.get5', array('flat' => 1));
     $this->assertNotEmpty(ViewDataTableManager::getViewDataTableParameters('mylogin1', 'API.get1'));
     $this->assertNotEmpty(ViewDataTableManager::getViewDataTableParameters('mylogin1', 'API.get2'));
     $this->assertNotEmpty(ViewDataTableManager::getViewDataTableParameters('mylogin2', 'API.get3'));
     $this->assertNotEmpty(ViewDataTableManager::getViewDataTableParameters('mylogin1', 'API.get4'));
     $this->assertNotEmpty(ViewDataTableManager::getViewDataTableParameters('mylogin3', 'API.get5'));
     ViewDataTableManager::clearAllViewDataTableParameters();
     $this->assertEmpty(ViewDataTableManager::getViewDataTableParameters('mylogin1', 'API.get1'));
     $this->assertEmpty(ViewDataTableManager::getViewDataTableParameters('mylogin1', 'API.get2'));
     $this->assertEmpty(ViewDataTableManager::getViewDataTableParameters('mylogin2', 'API.get3'));
     $this->assertEmpty(ViewDataTableManager::getViewDataTableParameters('mylogin1', 'API.get4'));
     $this->assertEmpty(ViewDataTableManager::getViewDataTableParameters('mylogin3', 'API.get5'));
 }
 public function onEnvironmentBootstrapped()
 {
     if (empty($_GET['ignoreClearAllViewDataTableParameters'])) {
         // TODO: should use testingEnvironment variable, not query param
         try {
             \Piwik\ViewDataTable\Manager::clearAllViewDataTableParameters();
         } catch (\Exception $ex) {
             // ignore (in case DB is not setup)
         }
     }
     if ($this->vars->optionsOverride) {
         try {
             foreach ($this->vars->optionsOverride as $name => $value) {
                 Option::set($name, $value);
             }
         } catch (\Exception $ex) {
             // ignore (in case DB is not setup)
         }
     }
     \Piwik\Plugins\CoreVisualizations\Visualizations\Cloud::$debugDisableShuffle = true;
     \Piwik\Visualization\Sparkline::$enableSparklineImages = false;
     \Piwik\Plugins\ExampleUI\API::$disableRandomness = true;
     if ($this->vars->deleteArchiveTables && !$this->vars->_archivingTablesDeleted) {
         $this->vars->_archivingTablesDeleted = true;
         DbHelper::deleteArchiveTables();
     }
 }
Esempio n. 3
0
 public static function addHooks()
 {
     $testingEnvironment = new Piwik_TestingEnvironment();
     if ($testingEnvironment->queryParamOverride) {
         foreach ($testingEnvironment->queryParamOverride as $key => $value) {
             $_GET[$key] = $value;
         }
     }
     if ($testingEnvironment->globalsOverride) {
         foreach ($testingEnvironment->globalsOverride as $key => $value) {
             $GLOBALS[$key] = $value;
         }
     }
     if ($testingEnvironment->useXhprof) {
         \Piwik\Profiler::setupProfilerXHProf($mainRun = false, $setupDuringTracking = true);
     }
     Config::setSingletonInstance(new Config($testingEnvironment->configFileGlobal, $testingEnvironment->configFileLocal, $testingEnvironment->configFileCommon));
     \Piwik\CacheFile::$invalidateOpCacheBeforeRead = true;
     Piwik::addAction('Access.createAccessSingleton', function ($access) use($testingEnvironment) {
         if (!$testingEnvironment->testUseRegularAuth) {
             $access = new Piwik_MockAccess($access);
             \Piwik\Access::setSingletonInstance($access);
         }
     });
     if (!$testingEnvironment->dontUseTestConfig) {
         Piwik::addAction('Config.createConfigSingleton', function (Config $config, &$cache, &$local) use($testingEnvironment) {
             $config->setTestEnvironment($testingEnvironment->configFileLocal, $testingEnvironment->configFileGlobal, $testingEnvironment->configFileCommon);
             if ($testingEnvironment->configFileLocal) {
                 $local['General']['session_save_handler'] = 'dbtable';
             }
             $manager = \Piwik\Plugin\Manager::getInstance();
             $pluginsToLoad = $testingEnvironment->getCoreAndSupportedPlugins();
             if (!empty($testingEnvironment->pluginsToLoad)) {
                 $pluginsToLoad = array_unique(array_merge($pluginsToLoad, $testingEnvironment->pluginsToLoad));
             }
             sort($pluginsToLoad);
             $local['Plugins'] = array('Plugins' => $pluginsToLoad);
             $local['log']['log_writers'] = array('file');
             $manager->unloadPlugins();
             // TODO: replace this and below w/ configOverride use
             if ($testingEnvironment->tablesPrefix) {
                 $cache['database']['tables_prefix'] = $testingEnvironment->tablesPrefix;
             }
             if ($testingEnvironment->dbName) {
                 $cache['database']['dbname'] = $testingEnvironment->dbName;
             }
             if ($testingEnvironment->configOverride) {
                 $cache = $testingEnvironment->arrayMergeRecursiveDistinct($cache, $testingEnvironment->configOverride);
             }
         });
     }
     Piwik::addAction('Request.dispatch', function () use($testingEnvironment) {
         if (empty($_GET['ignoreClearAllViewDataTableParameters'])) {
             // TODO: should use testingEnvironment variable, not query param
             \Piwik\ViewDataTable\Manager::clearAllViewDataTableParameters();
         }
         if ($testingEnvironment->optionsOverride) {
             foreach ($testingEnvironment->optionsOverride as $name => $value) {
                 Option::set($name, $value);
             }
         }
         \Piwik\Plugins\CoreVisualizations\Visualizations\Cloud::$debugDisableShuffle = true;
         \Piwik\Visualization\Sparkline::$enableSparklineImages = false;
         \Piwik\Plugins\ExampleUI\API::$disableRandomness = true;
     });
     Piwik::addAction('AssetManager.getStylesheetFiles', function (&$stylesheets) {
         $stylesheets[] = 'tests/resources/screenshot-override/override.css';
     });
     Piwik::addAction('AssetManager.getJavaScriptFiles', function (&$jsFiles) {
         $jsFiles[] = 'tests/resources/screenshot-override/override.js';
     });
     self::addSendMailHook();
     Piwik::addAction('Updater.checkForUpdates', function () {
         try {
             @\Piwik\Filesystem::deleteAllCacheOnUpdate();
         } catch (Exception $ex) {
             // pass
         }
     });
     $testingEnvironment->logVariables();
     $testingEnvironment->executeSetupTestEnvHook();
 }
Esempio n. 4
0
<?php

/**
 * Proxy to index.php, but will use the Test DB
 * Used by tests/PHPUnit/Integration/ImportLogsTest.php and tests/PHPUnit/Integration/UITest.php
 */
require realpath(dirname(__FILE__)) . "/includes.php";
Piwik_TestingEnvironment::addHooks();
if (empty($_GET['ignoreClearAllViewDataTableParameters'])) {
    \Piwik\ViewDataTable\Manager::clearAllViewDataTableParameters();
}
\Piwik\Profiler::setupProfilerXHProf();
include PIWIK_INCLUDE_PATH . '/index.php';