예제 #1
0
 /**
  * Create adapter
  *
  * @param string $adapterName database adapter name
  * @param array $dbInfos database connection info
  * @param bool $connect
  * @return AdapterInterface
  */
 public static function factory($adapterName, &$dbInfos, $connect = true)
 {
     if ($connect) {
         if ($dbInfos['port'][0] == '/') {
             $dbInfos['unix_socket'] = $dbInfos['port'];
             unset($dbInfos['host']);
             unset($dbInfos['port']);
         }
         // not used by Zend Framework
         unset($dbInfos['tables_prefix']);
         unset($dbInfos['adapter']);
         unset($dbInfos['schema']);
     }
     $className = self::getAdapterClassName($adapterName);
     Loader::loadClass($className);
     /*
      * 5.2.1 fixes various bugs with references that caused PDO_MYSQL getConnection()
      * to clobber $dbInfos. (#33282, #35106, #39944)
      */
     if (version_compare(PHP_VERSION, '5.2.1') < 0) {
         $adapter = new $className(array_map('trim', $dbInfos));
     } else {
         $adapter = new $className($dbInfos);
     }
     if ($connect) {
         $adapter->getConnection();
         Zend_Db_Table::setDefaultAdapter($adapter);
         // we don't want the connection information to appear in the logs
         $adapter->resetConfig();
     }
     return $adapter;
 }
예제 #2
0
 /**
  * Return the SMSProvider associated to the provider name $providerName
  *
  * @throws Exception If the provider is unknown
  * @param string $providerName
  * @return \Piwik\Plugins\MobileMessaging\SMSProvider
  */
 public static function factory($providerName)
 {
     $className = __NAMESPACE__ . '\\SMSProvider\\' . $providerName;
     try {
         Loader::loadClass($className);
         return new $className();
     } catch (Exception $e) {
         throw new Exception(Piwik::translate('MobileMessaging_Exception_UnknownProvider', array($providerName, implode(', ', array_keys(self::$availableSMSProviders)))));
     }
 }
예제 #3
0
 /**
  * Return the StaticGraph according to the static graph type $graphType
  *
  * @throws Exception If the static graph type is unknown
  * @param string $graphType
  * @return \Piwik\Plugins\ImageGraph\StaticGraph
  */
 public static function factory($graphType)
 {
     if (isset(self::$availableStaticGraphTypes[$graphType])) {
         $className = self::$availableStaticGraphTypes[$graphType];
         $className = __NAMESPACE__ . "\\StaticGraph\\" . $className;
         Loader::loadClass($className);
         return new $className();
     } else {
         throw new Exception(Piwik::translate('General_ExceptionInvalidStaticGraphType', array($graphType, implode(', ', self::getAvailableStaticGraphTypes()))));
     }
 }
예제 #4
0
 /**
  * Return the ReportRenderer associated to the renderer type $rendererType
  *
  * @throws exception If the renderer is unknown
  * @param string $rendererType
  * @return \Piwik\ReportRenderer
  */
 public static function factory($rendererType)
 {
     $name = ucfirst(strtolower($rendererType));
     $className = 'Piwik\\ReportRenderer\\' . $name;
     try {
         Loader::loadClass($className);
         return new $className();
     } catch (Exception $e) {
         @header('Content-Type: text/html; charset=utf-8');
         throw new Exception(Piwik::translate('General_ExceptionInvalidReportRendererFormat', array($name, implode(', ', self::$availableReportRenderers))));
     }
 }
예제 #5
0
 /**
  * Create adapter
  *
  * @param string $adapterName database adapter name
  * @param array $dbInfos database connection info
  * @param bool $connect
  * @return AdapterInterface
  */
 public static function factory($adapterName, &$dbInfos, $connect = true)
 {
     if ($connect) {
         if ($dbInfos['port'][0] == '/') {
             $dbInfos['unix_socket'] = $dbInfos['port'];
             unset($dbInfos['host']);
             unset($dbInfos['port']);
         }
         // not used by Zend Framework
         unset($dbInfos['tables_prefix']);
         unset($dbInfos['adapter']);
         unset($dbInfos['schema']);
     }
     $className = self::getAdapterClassName($adapterName);
     Loader::loadClass($className);
     $adapter = new $className($dbInfos);
     if ($connect) {
         $adapter->getConnection();
         Zend_Db_Table::setDefaultAdapter($adapter);
         // we don't want the connection information to appear in the logs
         $adapter->resetConfig();
     }
     return $adapter;
 }
예제 #6
0
    define('PIWIK_USER_PATH', PIWIK_PATH_TEST_TO_ROOT);
}
if (!defined('PIWIK_INCLUDE_PATH')) {
    define('PIWIK_INCLUDE_PATH', PIWIK_PATH_TEST_TO_ROOT);
}
if (!defined('PIWIK_INCLUDE_SEARCH_PATH')) {
    define('PIWIK_INCLUDE_SEARCH_PATH', get_include_path() . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/vendor/bin' . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/core' . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/libs' . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/plugins');
}
@ini_set('include_path', PIWIK_INCLUDE_SEARCH_PATH);
@set_include_path(PIWIK_INCLUDE_SEARCH_PATH);
@ini_set('memory_limit', -1);
error_reporting(E_ALL | E_NOTICE);
@date_default_timezone_set('UTC');
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
\Piwik\Loader::init();
\Piwik\Loader::registerTestNamespace();
require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php';
require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php';
require_once PIWIK_INCLUDE_PATH . '/core/FrontController.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Fixture.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/DatabaseTestCase.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/IntegrationTestCase.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/ConsoleCommandTestCase.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/BenchmarkTestCase.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/FakeAccess.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/TestingEnvironment.php';
if (getenv('PIWIK_USE_XHPROF') == 1) {
    \Piwik\Profiler::setupProfilerXHProf();
}
// require test fixtures
$fixturesToLoad = array('/tests/PHPUnit/Fixtures/*.php', '/tests/PHPUnit/UI/Fixtures/*.php', '/plugins/*/tests/Fixtures/*.php', '/plugins/*/Test/Fixtures/*.php');
예제 #7
0
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 * @package Piwik
 */
if (!defined('PIWIK_DOCUMENT_ROOT')) {
    define('PIWIK_DOCUMENT_ROOT', dirname(__FILE__) == '/' ? '' : dirname(__FILE__));
}
if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) {
    require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php';
}
error_reporting(E_ALL | E_NOTICE);
@ini_set('display_errors', defined('PIWIK_DISPLAY_ERRORS') ? PIWIK_DISPLAY_ERRORS : @ini_get('display_errors'));
@ini_set('xdebug.show_exception_trace', 0);
@ini_set('magic_quotes_runtime', 0);
if (!defined('PIWIK_USER_PATH')) {
    define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT);
}
if (!defined('PIWIK_INCLUDE_PATH')) {
    define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT);
}
require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php';
// NOTE: the code above this comment must be PHP4 compatible
require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php';
session_cache_limiter('nocache');
@date_default_timezone_set('UTC');
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
\Piwik\Loader::init();
if (!defined('PIWIK_PRINT_ERROR_BACKTRACE')) {
    define('PIWIK_PRINT_ERROR_BACKTRACE', false);
}
require_once PIWIK_INCLUDE_PATH . '/core/dispatch.php';
예제 #8
0
 private function requireFixtureFiles(InputInterface $input)
 {
     \Piwik\Loader::registerTestNamespace();
     require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php';
     require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/FakeAccess.php';
     require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/TestingEnvironment.php';
     require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/IntegrationTestCase.php';
     require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Fixture.php';
     $fixturesToLoad = array('/tests/PHPUnit/Fixtures/*.php', '/tests/PHPUnit/UI/Fixtures/*.php', '/plugins/*/tests/Fixtures/*.php', '/plugins/*/Test/Fixtures/*.php');
     foreach ($fixturesToLoad as $fixturePath) {
         foreach (glob(PIWIK_INCLUDE_PATH . $fixturePath) as $file) {
             require_once $file;
         }
     }
     $file = $input->getOption('file');
     if ($file) {
         if (is_file($file)) {
             require_once $file;
         } else {
             if (is_file(PIWIK_INCLUDE_PATH . '/' . $file)) {
                 require_once PIWIK_INCLUDE_PATH . '/' . $file;
             } else {
                 throw new \Exception("Cannot find --file option file '{$file}'.");
             }
         }
     }
 }