Exemplo n.º 1
0
 public function run()
 {
     $test = new GroupTest("Piwik - running '{$this->testGroupType}' tests...");
     $intro = '';
     if (!$this->databaseRequired) {
         $intro .= $this->getTestDatabaseInfoMessage();
     }
     $intro .= self::$testsHelpLinks . "<hr/>";
     $intro .= $this->introAppend;
     $toInclude = array();
     foreach ($this->dirsToGlob as $dir) {
         $toInclude = array_merge($toInclude, Piwik::globr(PIWIK_INCLUDE_PATH . $dir, '*.test.php'));
     }
     // if present, make sure Database.test.php is first
     $idx = array_search(PIWIK_INCLUDE_PATH . '/tests/core/Database.test.php', $toInclude);
     if ($idx !== FALSE) {
         unset($toInclude[$idx]);
         array_unshift($toInclude, PIWIK_INCLUDE_PATH . '/tests/core/Database.test.php');
     }
     foreach ($toInclude as $file) {
         $test->addFile($file);
     }
     $result = $test->run(new HtmlTimerReporter($intro));
     if (SimpleReporter::inCli()) {
         exit($result ? 0 : 1);
     }
 }
Exemplo n.º 2
0
Arquivo: Db.php Projeto: ntulip/piwik
 /**
  * Get list of adapters
  *
  * @return array
  */
 public static function getAdapters()
 {
     $path = PIWIK_INCLUDE_PATH . '/core/Db';
     $pathLength = strlen($path) + 1;
     $adapters = Piwik::globr($path, '*.php');
     $adapterNames = array();
     foreach ($adapters as $adapter) {
         $adapterName = str_replace('/', '_', substr($adapter, $pathLength, -strlen('.php')));
         $className = 'Piwik_Db_' . $adapterName;
         if (call_user_func(array($className, 'isEnabled'))) {
             $adapterNames[strtoupper($adapterName)] = call_user_func(array($className, 'getDefaultPort'));
         }
     }
     return $adapterNames;
 }
Exemplo n.º 3
0
 function test_svnKeywords()
 {
     /*
      * Piwik's .php files have $Id: $
      */
     $contents = file_get_contents($file = PIWIK_DOCUMENT_ROOT . '/index.php');
     $this->assertTrue(strpos($contents, '$Id: ' . basename($file) . ' ') !== false, $file);
     $contents = file_get_contents($file = PIWIK_DOCUMENT_ROOT . '/piwik.php');
     $this->assertTrue(strpos($contents, '$Id: ' . basename($file) . ' ') !== false, $file);
     foreach (Piwik::globr(PIWIK_DOCUMENT_ROOT . '/core', '*.php') as $file) {
         $contents = file_get_contents($file);
         $this->assertTrue(strpos($contents, '$Id: ' . basename($file) . ' ') !== false, $file);
     }
     foreach (Piwik::globr(PIWIK_DOCUMENT_ROOT . '/plugins', '*.php') as $file) {
         if (strpos($file, '/tests/') !== false || strpos($file, '/config/') !== false || strpos($file, '/PhpSecInfo/') !== false || strpos($file, 'tcpdf_config.php') !== false) {
             continue;
         }
         $contents = file_get_contents($file);
         $this->assertTrue(strpos($contents, '$Id: ') !== false, $file . " Please add '@version \$Id: \$' in the file header comments");
     }
     /*
      * Piwik's .js files don't have $Id$ (information disclosure)
      */
     $contents = file_get_contents($file = PIWIK_DOCUMENT_ROOT . '/piwik.js');
     $this->assertTrue(strpos($contents, '$Id') === false, $file);
     $contents = file_get_contents($file = PIWIK_DOCUMENT_ROOT . '/js/piwik.js');
     $this->assertTrue(strpos($contents, '$Id') === false, $file);
     foreach (Piwik::globr(PIWIK_DOCUMENT_ROOT . '/plugins', '*.js') as $file) {
         $contents = file_get_contents($file);
         $found = strpos($contents, '$Id') !== false;
         $this->assertTrue(!$found, $file, "Please Remove the string \$Id from the JS files");
     }
     foreach (Piwik::globr(PIWIK_DOCUMENT_ROOT . '/themes', '*.js') as $file) {
         $contents = file_get_contents($file);
         $this->assertTrue(strpos($contents, '$Id') === false, $file);
     }
 }
Exemplo n.º 4
0
<?php

require_once 'config_test.php';
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/mock_objects.php';
require_once 'simpletest/collector.php';
require_once 'simpletest/default_reporter.php';
// if SCRIPT_NAME points to benchmark_runner.php, load every benchmark group in benchmarks folder
if (preg_match("/benchmark_runner.php\$/", $_SERVER['SCRIPT_NAME'])) {
    foreach (Piwik::globr(PIWIK_INCLUDE_PATH . '/tests/benchmarks', '*.benchmark.php') as $file) {
        require_once $file;
    }
}
function display_runner($benchmarkGroups)
{
    ?>
<html>
<head>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
	<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" type="text/css" media="screen"></link>
	<title>Benchmarks | Piwik</title>
</head>
<body>
	<style>
		td.elapsed {
			font-weight: bold;
		}
		td.status {
			font-style: italic;
		}