From 624a06add57e1bf7dee0a090ddf4680265552158 Mon Sep 17 00:00:00 2001 From: Ludovic Demblans Date: Mon, 29 Aug 2011 18:04:09 +0200 Subject: [PATCH] simple stats ok --- classes/application.php | 24 ++ classes/counter.php | 484 ++++++++-------------------------------- classes/section.php | 60 ++++- tests/tests.php | 157 +++++++------ 4 files changed, 262 insertions(+), 463 deletions(-) diff --git a/classes/application.php b/classes/application.php index c6ff548..b9a4955 100644 --- a/classes/application.php +++ b/classes/application.php @@ -54,6 +54,22 @@ public function get_counter($key, $section) { return new TWStats_Counter($key, $section, $this); } + public function get_counter_by_id($id) { + + $table_name = $this->get_table_name('counters'); + $query = 'select * from counters where id = :id'; + $statement = $this->pdo_prepare($query); + $statement->execute(array('id' => $id)); + $row = $statement->fetch(PDO::FETCH_ASSOC); + $section_id = $row['section_id']; + $section = $this->get_section_by_id($section_id); + + + $counter = new TWStats_Counter($row['strkey'], $section, $this); + $counter->set_id($id); + return $counter; + } + /** * * @param $path @@ -63,6 +79,14 @@ public function get_section($path) { return new TWStats_Section($path, $this); } + public function get_section_by_id($id) { + $section = new TWStats_Section(array(), $this); + $section->set_id($id); + $section->set_path_from_id(); + return $section; + } + + public function create_section($path) { diff --git a/classes/counter.php b/classes/counter.php index 7f3d35a..4386632 100644 --- a/classes/counter.php +++ b/classes/counter.php @@ -76,8 +76,8 @@ public function commit($new_day_if_not_exists=true) { if ($rowcount != 1) if ($new_day_if_not_exists) { - // ici, enregistrer le compteur à la date du jour dans la base, - // puis réessayer +// ici, enregistrer le compteur à la date du jour dans la base, +// puis réessayer $this->create_today(); // on crée le compteur return $this->commit(false); //: /* on passe à false, @@ -105,13 +105,21 @@ private function name() { return $this->_display_name; } + public function set_id($id) { + + $this->_id = $id; + } + + public function get_id() { + return $this->id(); + } + private function id() { if (empty($this->_id)) { $section_id = $this->_section->id(); $query = sprintf( 'select * from %s where strkey like :key and section_id = :s_id', - $this->_app->get_table_name('counters'), - $this->_strkey + $this->_app->get_table_name('counters') ); $statement = $this->_app->pdo_prepare($query); $statement->execute(array( @@ -161,411 +169,105 @@ private function create_today() { $statement->execute(array('id' => $this->id())); } -} - -class TWStats_Counter_OLD { - - private $_conf; - /** - * Chemin dans les sections, sous forme de tableau - * exemple array('annuaire', 'immolocationoffre', 'ApptT2') - */ - private $_path; - private $_key; - private $_keyname; - private $_counter_id; - private $_section_id; - /** - * Champs à incrémenter. une valeur de 3 incrémentera les hits et visites - * @var binary,int - */ - private $_increments; - - /** - * valeur de retour possible pour getSectionIDByPath - */ - // const unknown_section = false; - - /** - * Choix des compteurs à incrémenter - */ - const increment_hit = 1; - const increment_visit = 2; - const increment_dayvisit = 4; - - public function __construct($key, array $path, TWStats_Application $app) { - - - // Validation des sections - - if (!is_array($path) || count($path) < 1) - throw new InvalidArgumentException('Bad path or empty path'); - - - // // protection - foreach ($path as &$token) { - $token = $this->string_simplification($token); - } - - $this->_path = $path; - - // Validation de la clé - - if ((string) $key == '') - throw new InvalidArgumentException('Empty key'); - - - $this->_key = $this->string_simplification($key); - - $this->_increments = 0; - - if (!isset($this->_conf['table_prefix'])) - $this->_conf['table_prefix'] = ''; - } - - private function section_id() { - if (empty($this->_section_id)) - $this->_section_id = $this->sectionIDFromPath($this->_path); - return $this->_section_id; - } - - private function counter_id() { - if (empty($this->_counter_id)) { - $query = sprintf('select * from %scounters where strkey like - \'%s\' and section_id = %d', - $this->conf('table_prefix'), - $this->_key, - $this->section_id()); - - $rs_a = $this->conf('pdo')->query($query)->fetchAll(PDO::FETCH_ASSOC); - - $count = count($rs_a); - if ($count == 0) - $this->_counter_id = $this->registerNewCounter($this->_key, $this->section_id()); - elseif ($count == 1) - $this->_counter_id = intval($rs_a[0]['id']); - else - throw new Exception("duplicate strkey/section_id .. too bad! ($count found)"); - } - return $this->_counter_id; - } - -//============================================================================== -//=================== CREATION DES CLES ET DES SECTIONS ======================== -//============================================================================== - - /** - * renvoie l'id d'une section selon le path, les sections sont créées - * si elles n'existent pas - */ - private function sectionIDFromPath($path) { - - if (count($path) == 0) - return 0; - - $section_name = array_pop($path); // <-- POP! - $sql_id_by_name = sprintf( - 'select id, parent_id from %ssections where name like \'%s\'', - $this->conf('table_prefix'), - $section_name + public function dump() { + return array( + 'strkey' => $this->_strkey, + 'name' => $this->display_name(), + 'display_name' => $this->_display_name, + 'id' => $this->id(), + 'parent_id' => $this->_section->id() ); - $rs = $this->conf('pdo')->query($sql_id_by_name); - $rows = $rs->fetchAll(PDO::FETCH_ASSOC); - - /* Ici la technique est simple : - * - 1 seule ligne, la section est trouvée - * - X lignes, on compare le parent_id avec une récursion sur la - * pile $path - */ - - $num_rows = count($rows); - - // if ($num_rows == 1) -// return $rows[0]['id']; - // else { - $parent_id = $this->sectionIDFromPath($path); // <-- see POP - foreach ($rows as $row) - if ($row['parent_id'] == $parent_id) - return $row['id']; - // ici aucune correspondance n'a été établie, on crée - return $this->registerNewSection($section_name, $parent_id); - // } } - /** - * Enregistre une section dans la base de données. - * Un parent_id 0 donnera une section de premier niveau. - * Renvoie l'id de la section nouvellement créée. - * @param string $name - * @param int $parent_id - * @return int - */ - private function registerNewSection($name, $parent_id) { - $pdo = $this->conf('pdo'); - $statement = $pdo->prepare(sprintf( - 'insert into %ssections (name, parent_id) VALUES (:name, :parent_id)', - $this->conf('table_prefix'))); - + public function display_name() { - try { - $statement->execute(array('name' => $name, 'parent_id' => $parent_id)); - } - catch (PDOException $e) { - throw new PDOException('[registerNewSection] ' . $e->getMessage(), - $e->getCode()); - } - return $pdo->lastInsertId(); + return empty($this->_display_name) ? $this->_strkey : + $this->_display_name; } - /** - * Enregistre un item dans la base de données. - * Renvoie l'id de l'item créé. - * @param string $key - * @param int $section_id - * @return int - */ - private function registerNewCounter($strkey, $section_id) { - - $pdo = $this->conf('pdo'); - $statement = $pdo->prepare(sprintf( - 'insert into %scounters (strkey, section_id) VALUES (:strkey, :section_id)', - $this->conf('table_prefix'))); - - try { - $statement->execute(array('strkey' => $strkey, 'section_id' => $section_id)); - } - catch (PDOException $e) { - throw $e; - } - - $key_id = $pdo->lastInsertId(); - - if (isset($this->_keyname)) { - $statement = $pdo->prepare('update counters set name = :name where id = :id'); - try { - $statement->execute(array('id' => $key_id, 'name' => $this->_keyname)); - } - catch (PDOException $e) { - // ici on ne fait rien. pour le moment, inutile de - // bloquer l'application pour un nom alors que le - // décompte fonctionne - } - } - - return intval($key_id); - } - - /* permet de remplir le champ d'affichage des clés en base de données - * automatiquement, afin d'avoir un affichage plus lisible - * - * Utilisé dans la fonction registerNewCounter - */ - - private function set_key_name($name) { - $this->_keyname = $name; - } - -//============================================================================== -//=================== INCREMENTATION DES COMPTEURS ============================= -//============================================================================== - - /** - * Incrémente le compteur de hits à chaque appel - */ - private function hit() { - $this->_increments = $this->_increments | self::increment_hit; - return $this; - } - - /** - * Incrémente le compteur uniquement si le marqueur n'est pas présent en - * session - */ - private function visit() { + public function stats($first_day, $last_day, $data_grain) { + //@todo mettre ça dans une config, c'est side effect donc ça n'a + // rien à faire dans une classe + setlocale(LC_ALL, 'fr_FR.utf8'); + date_default_timezone_set('Europe/Paris'); + if ($data_grain == 'day') + return $this->stats_day($first_day, $last_day); + else { - if (!session_id()) - session_start(); - if (isset($_SESSION) - && !isset($_SESSION[$this->conf('session_hash')][$this->counter_id()])) { - $this->_increments = $this->_increments | self::increment_visit; + return $this->stats_grain($first_day, $last_day, $data_grain); } - return $this; } - /** - * Incrémente le compteur si la valeur du cookie n'est pas la date du jour - * Un seul cookie pour tous les keyid est utilisé, séparé par _ - * + le cookie pour la date - */ - private function dayvisit() { - $today = (int) date('Ymd'); - /* si le cookie n'est pas du jour */ - if (!$this->already_visited_today() || - (int) $_COOKIE[$this->conf('cookie_date_hash')] != $today) { - $this->_increments = $this->_increments | self::increment_dayvisit; + private function stats_day($first_day, $last_day) { + $q = ' + select hits, + visits, + day_visits, + day_date as datekey + from ' . $this->_app->get_table_name('counters_days') . ' + where counter_id = :counter_id and + day_date >= :first_day and + day_date <= :last_day + order by day_date + '; + $statement = $this->_app->pdo_prepare($q); + $statement->execute(array( + 'counter_id' => $this->id(), + 'first_day' => $first_day, + 'last_day' => $last_day + )); + $rs = $statement->fetchAll(PDO::FETCH_ASSOC); + + foreach ($rs as &$v) { //!& + $v['datetitle'] = strftime("%A %d %b", strtotime($v['datekey'])); } - /* si le cookie est du jour, on va voir si la page actuelle est vue */ - return $this; + return $rs; } - private function already_visited_today() { - return ( - isset($_COOKIE[$this->conf('cookie_date_hash')]) && - (int) $_COOKIE[$this->conf('cookie_date_hash')] == (int) date('Ymd') && - isset($_COOKIE[$this->conf('cookie_ids_hash')]) && - strstr($_COOKIE[$this->conf('cookie_ids_hash')], '_' . $this->counter_id()) !== false - ); - } + private function stats_grain($first_day, $last_day, $data_grain) { - /** - * Remplace ou crée le cookie $this->cookie_date_hash par la date du jour - */ - private function setDateCookie() { - $today = (int) date('Ymd'); - $expire = time() + 3600 * 24; // 1 jour - return - setcookie($this->conf('cookie_date_hash'), $today, $expire) && - setcookie($this->conf('cookie_ids_hash')); // On supprime également les pages du jour précédent - } - - /** - * Renvoie true si le keyid est ajouté, false s'il y est déjà - */ - private function addKey2Cookie() { - $expire = time() + 3600 * 24; // 1 jour - - if ($this->already_visited_today()) - return false; - - if (isset($_COOKIE[$this->conf('cookie_ids_hash')])) - $base_str = $_COOKIE[$this->conf('cookie_ids_hash')]; - else - $base_str = ''; - - setcookie($this->conf('cookie_ids_hash'), $base_str . '_' . $this->counter_id(), $expire); - return true; - } - - /** - * Donne une pertie de requête SQL destinée à incrémenter les champs du - * compteur, en fonction des valeurs contenues dans this->increments - * @return string - */ - private function getIncrementsQuery() { - $tabsql = array(); - $this->_increments & self::increment_hit - && $tabsql[] = 'hits = hits + 1'; - $this->_increments & self::increment_visit - && $tabsql[] = 'visits = visits + 1'; - $this->_increments & self::increment_dayvisit - && $tabsql[] = 'day_visits = day_visits + 1'; - if (count($tabsql) > 0) - return implode(', ', $tabsql); - else { - throw new Exception('Can\'t count nothing..'); - } - } - /** - * Déclenche l'update des compteurs dans la base de données. - * Si le compteur et le jour n'existaient pas déjà, mettre $try_insert à - * true (valeur par défaut) permet de le créer - * Reset la valeur de this->increments à 0; - * @param bool $try_insert - */ - private function commit($try_insert=true) { - $sql_update = sprintf( - 'update %scounters_days' . - ' set %s where counter_id = %s and day_date = date(now())', - $this->conf('table_prefix'), - $this->getIncrementsQuery(), - $this->counter_id() + $grains = array( + 'month' => 'y,m', + 'year' => 'y' ); - - - - - $rowcount = $this->conf('pdo')->exec($sql_update); - if ($rowcount != 1 && $try_insert) { - // ici, enregistrer le compteur à la date du jour dans la base, - // puis réessayer - $this->registerNewCountDay(); // on crée le compteur - return $this->commit(false); //: - /* on passe à false, - * si la création ne fonctionne pas - * comme ça pas de boucle infinie - */ + $grain = $grains[$data_grain]; + $q = ' + select sum(hits) as hits, + sum(visits) as visits, + sum(day_visits) as day_visits, + min(day_date) as mindate, + YEAR(day_date) as y, + MONTH(day_date) as m + from ' . $this->_app->get_table_name('counters_days') . ' + where counter_id = :counter_id and + day_date >= :first_day and + day_date <= :last_day + group by ' . $grain . ' + order by ' . $grain . ' + '; + $statement = $this->_app->pdo_prepare($q); + $statement->execute(array( + 'counter_id' => $this->id(), + 'first_day' => $first_day, + 'last_day' => $last_day + )); + $rs = $statement->fetchAll(PDO::FETCH_ASSOC); + + if ($data_grain == 'month') { + foreach ($rs as &$v) { //!& + $v['datekey'] = $v['y'] . '-' . $v['m'] . '-01'; + $v['datetitle'] = strftime("%b %Y", strtotime($v['mindate'])); + } } - - /* Si une visit à été demandée, commit sur la session */ - $this->_increments & self::increment_visit && - $_SESSION[$this->conf('session_hash')][$this->counter_id()] = 'increment'; - - /* Si une dayvisit à été demandée, on commit aussi sur les cookies */ - $this->_increments & self::increment_dayvisit && - $this->setDateCookie() && $this->addKey2Cookie(); - - $this->_increments = 0; - return $this; - } - - /** - * Enregistre dans la base une paire item/jour avec les compteurs à 0 - */ - private function registerNewCountDay() { - $sql_insert = sprintf( - 'insert into %scounters_days' . - ' (counter_id, day_date, hits,visits, day_visits)' . - ' VALUES (%d, date(now()), 0,0,0)', - $this->conf('table_prefix'), - $this->counter_id() - ); - $exec = $this->conf('pdo')->exec($sql_insert); - } - -//============================================================================== -//========================== LECTURE DES COMPTEURS ============================= -//============================================================================== - - /** - * $day_date = format Y-m-d - * */ - private function read_date($day_date) { - - - $sql = sprintf( - 'select hits, visits, day_visits from %scounters_days ' . - 'where counter_id = :counter_id and day_date = :day_date', - $this->conf('table_prefix')); - $statement = $this->conf('pdo')->prepare($sql); - $statement->execute(array('counter_id' => $this->counter_id(), - 'day_date' => $day_date)); - if ($statement->rowCount()) - return $statement->fetch(PDO::FETCH_ASSOC); - else - return array('hits' => 0, 'visits' => 0, 'day_visits' => 0); - } - - /* - * both date params included - * */ - - private function read_interval($day_date_start, $day_date_end) { - - - $sql = sprintf( - 'select hits, visits, day_visits from %scounters_days ' . - 'where counter_id = :counter_id and - day_date >= :day_date_start and - day_date <= :day_date_end', - $this->conf('table_prefix')); - $statement = $this->conf('pdo')->prepare($sql); - $statement->execute(array('counter_id' => $this->counter_id(), - 'day_date_start' => $day_date_start, - 'day_date_end' => $day_date_end)); - return $statement->fetchAll(PDO::FETCH_ASSOC); + elseif ($data_grain == 'year') { + foreach ($rs as &$v) { //!& + $v['datekey'] = $v['y'] . '-01-01'; + $v['datetitle'] = strftime("%Y", strtotime($v['mindate'])); + } + } + return $rs; } } - diff --git a/classes/section.php b/classes/section.php index 95505cd..b626fa8 100644 --- a/classes/section.php +++ b/classes/section.php @@ -1,5 +1,11 @@ refaire l'appli plus simplement + */ + class TWStats_Section { private $_path; @@ -28,11 +34,37 @@ public function __construct(array $path, TWStats_Application $app) { $this->_app = $app; } - private function set_id($id) { + public function set_id($id) { $this->_id = $id; } + public function set_path_from_id() { + if ($this->_id == 0) { + $this->_name = 'ROOT_SECTION'; + $this->_path = array(); + return; + } + // else + $sql_id_by_name = sprintf( + 'select * from %s where id = :id', + $this->_app->get_table_name('sections') + ); + $statement = $this->_app->pdo_prepare($sql_id_by_name); + $query_args = array( + 'id' => $this->_id + ); + $statement->execute($query_args); + $rs = $statement->fetch(PDO::FETCH_ASSOC); + $this->_name = $rs['name']; + $parent = $this->_app->get_section_by_id($rs['parent_id']); + $this->_path = array_merge($parent->get_path(), array($this->_name)); + } + + public function get_path() { + return $this->_path; + } + private function set_display_name($str) { $this->_display_name = $str; @@ -139,5 +171,31 @@ public function childs() { return $sections; } + public function get_counters() { + $query = sprintf( + 'select * from %s where section_id = :section_id', + $this->_app->get_table_name('counters') + ); + $statement = $this->_app->pdo_prepare($query); + $statement->execute(array('section_id' => $this->id())); + + $counters_a = $statement->fetchAll(PDO::FETCH_ASSOC); + $counters = array(); + foreach ($counters_a as $ct) { + $counter = $this->_app->get_counter($ct['strkey'], $this); + $counter->set_id($ct['id']); + $counters[] = $counter; + } + return $counters; + } + + public function get_counters_a() { + $counters = array(); + foreach ($this->get_counters() as $counter) { + $counters[] = $counter->dump(); + } + return $counters; + } + } diff --git a/tests/tests.php b/tests/tests.php index e338a87..a3e669a 100755 --- a/tests/tests.php +++ b/tests/tests.php @@ -1,6 +1,5 @@ #!/usr/local/bin/php assertTrue($twstats->get_table_name('counters') == 'test_counters'); @@ -35,10 +34,20 @@ function test_app() { return $twstats; } - + function test__get_counter_by_id() { + + $twstats = TestOfApp::test_app(); +// $section = TestOfSection::test_section(); + $counter = TestOfCounter::test_counter(); + $id = $counter->get_id(); + $counter = $twstats->get_counter_by_id($id); + $this->assertTrue($counter instanceof TWStats_Counter); + } + } class TestOfSection extends UnitTestCase { + function test_section() { $twstats = TestOfApp::test_app(); $path = array('sectiontest1', 'section1.1', 'section1.1.1'); @@ -52,127 +61,133 @@ function test_id() { $this->assertTrue(is_numeric($section->id())); $this->assertTrue($section->id() == intval($section->id())); } + } + class TestOfCounter extends UnitTestCase { + function test_counter() { $twstats = TestOfApp::test_app(); $section = TestOfSection::test_section(); $key = 'mycounter'; - - + + $counter = $twstats->get_counter($key, $section); $this->assertTrue($counter instanceof TWStats_Counter); $this->assertTrue($counter->hit() == $counter); $this->assertTrue($counter->commit()); + return $counter; } } -class TestCleanup extends UnitTestCase { - function test_cleanup_tables () { +class TestCleanup extends UnitTestCase { + + function test_cleanup_tables() { $twstats_config = GETCFG(); $pdo = $twstats_config['pdo']; // $pdo->exec('delete from counters ; delete from sections ; delete from counters_days'); } + } - /* - function test_CLEANUP() { - global $twstats_config; - $pdo = $twstats_config['pdo']; - //$pdo->exec('delete from counters'); - //$pdo->exec('delete from counters_days'); - //$pdo->exec('delete from sections'); - } +/* + function test_CLEANUP() { + global $twstats_config; + $pdo = $twstats_config['pdo']; + //$pdo->exec('delete from counters'); + //$pdo->exec('delete from counters_days'); + //$pdo->exec('delete from sections'); + } - function test_counter1 () { - global $twstats_config; - $this->assertTrue($twstats_config['pdo'] instanceof PDO); - $pdo = $twstats_config['pdo']; + function test_counter1 () { + global $twstats_config; + $this->assertTrue($twstats_config['pdo'] instanceof PDO); + $pdo = $twstats_config['pdo']; - // aucune clé pour le moment - //$this->assertTrue(count($pdo->query('select * from counters')->fetchAll()) == 0); - $path = array('sectiontest1', 'subtest1', 'sstest1'); - $key = 'keytest1'; - // création du compteur - $tw = new TWStats_Counter($path, $key, $twstats_config); - $this->assertTrue($tw instanceof TWStats_Counter); + // aucune clé pour le moment + //$this->assertTrue(count($pdo->query('select * from counters')->fetchAll()) == 0); + $path = array('sectiontest1', 'subtest1', 'sstest1'); + $key = 'keytest1'; + // création du compteur + $tw = new TWStats_Counter($path, $key, $twstats_config); + $this->assertTrue($tw instanceof TWStats_Counter); - // il ne doit pas y avoir de clé pour le moment non plus - //$this->assertTrue(count($pdo->query('select * from counters')->fetchAll()) == 0); + // il ne doit pas y avoir de clé pour le moment non plus + //$this->assertTrue(count($pdo->query('select * from counters')->fetchAll()) == 0); - //$this->assertTrue(is_integer($tw->counter_id())); + //$this->assertTrue(is_integer($tw->counter_id())); - //$tw->hit()->visit()->dayvisit()->commit(); - //$tw->hit()->visit()->dayvisit()->commit(); - //$tw->hit()->visit()->dayvisit()->commit(); - //$tw->hit()->visit()->dayvisit()->commit(); - } + //$tw->hit()->visit()->dayvisit()->commit(); + //$tw->hit()->visit()->dayvisit()->commit(); + //$tw->hit()->visit()->dayvisit()->commit(); + //$tw->hit()->visit()->dayvisit()->commit(); + } - function test_many_sections() { - global $twstats_config; + function test_many_sections() { + global $twstats_config; - $keyC = 2; + $keyC = 2; - $path = array('sectiontest1', 'subtest1', 'sstest1'); - $key = "keytest$keyC"; $keyC++; - // création du compteur - $tw = new TWStats_Counter($path, $key, $twstats_config); + $path = array('sectiontest1', 'subtest1', 'sstest1'); + $key = "keytest$keyC"; $keyC++; + // création du compteur + $tw = new TWStats_Counter($path, $key, $twstats_config); - $this->assertTrue(is_integer($tw->counter_id())); + $this->assertTrue(is_integer($tw->counter_id())); - $path = array('sectiontest1', 'subtest1', 'sstest1'); - $key = "keytest$keyC"; $keyC++; - // création du compteur - $tw = new TWStats_Counter($path, $key, $twstats_config); + $path = array('sectiontest1', 'subtest1', 'sstest1'); + $key = "keytest$keyC"; $keyC++; + // création du compteur + $tw = new TWStats_Counter($path, $key, $twstats_config); - $this->assertTrue(is_integer($tw->counter_id())); + $this->assertTrue(is_integer($tw->counter_id())); - $path = array('sectiontest1', 'subtest2', 'sstest1'); - $key = "keytest$keyC"; $keyC++; - // création du compteur - $tw = new TWStats_Counter($path, $key, $twstats_config); + $path = array('sectiontest1', 'subtest2', 'sstest1'); + $key = "keytest$keyC"; $keyC++; + // création du compteur + $tw = new TWStats_Counter($path, $key, $twstats_config); - $this->assertTrue(is_integer($tw->counter_id())); + $this->assertTrue(is_integer($tw->counter_id())); - $path = array('sectiontest1', 'subtest1', 'sstest1'); - $key = "keytest$keyC"; $keyC++; - // création du compteur - $tw = new TWStats_Counter($path, $key, $twstats_config); + $path = array('sectiontest1', 'subtest1', 'sstest1'); + $key = "keytest$keyC"; $keyC++; + // création du compteur + $tw = new TWStats_Counter($path, $key, $twstats_config); - $this->assertTrue(is_integer($tw->counter_id())); + $this->assertTrue(is_integer($tw->counter_id())); - $path = array('sectiontest1', 'subtest1', 'sstest1'); - $key = "keytest$keyC"; $keyC++; - // création du compteur - $tw = new TWStats_Counter($path, $key, $twstats_config); + $path = array('sectiontest1', 'subtest1', 'sstest1'); + $key = "keytest$keyC"; $keyC++; + // création du compteur + $tw = new TWStats_Counter($path, $key, $twstats_config); - $this->assertTrue(is_integer($tw->counter_id())); + $this->assertTrue(is_integer($tw->counter_id())); - } + } - function test_trees () { - global $twstats_config; - $this->assertTrue($twstats_config['pdo'] instanceof PDO); - $pdo = $twstats_config['pdo']; + function test_trees () { + global $twstats_config; + $this->assertTrue($twstats_config['pdo'] instanceof PDO); + $pdo = $twstats_config['pdo']; - $ui = new TWStats_UI($twstats_config); + $ui = new TWStats_UI($twstats_config); - echo('
'.$ui->CLI_Tree(0));
-	  }
+  echo('
'.$ui->CLI_Tree(0));
+  }
 
-	 */
+ */