123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <?php
- require_once(api_get_path(LIBRARY_PATH).'stats.lib.inc.php');
- class TestStats extends UnitTestCase {
- public function __construct() {
- $this->UnitTestCase('System stats library - main/inc/lib/stats.lib.test.php');
- }
- function testaddBrowser() {
- $browser='';
- $browsers_array=array();
- $res=addBrowser($browser,$browsers_array);
- $this->assertTrue(is_array($res));
- }
- function testaddCountry(){
- $country='';
- $countries_array=array();
- $res=addCountry($country,$countries_array);
- $this->assertTrue(is_array($res));
-
- }
- function testaddOs() {
- $os='';
- $os_array=array();
- $res=addOs($os,$os_array);
- $this->assertTrue(is_array($res));
-
- }
- function testaddProvider() {
- $provider='';
- $providers_array=array();
- $res=addProvider($provider,$providers_array);
- $this->assertTrue(is_array($res));
-
- }
- function testaddReferer() {
- $referer='';
- $referers_array=array();
- $res=addReferer($referer,$referers_array);
- $this->assertTrue(is_array($res));
-
- }
- function testcleanProcessedRecords() {
- global $TABLETRACK_OPEN;
- $limit='';
- $res=cleanProcessedRecords($limit);
- if(!is_null($res)) $this->assertTrue(is_string($res));
-
- }
- function testdecodeOpenInfos() {
-
- global $_course, $TABLETRACK_OPEN, $_configuration;
- $TABLETRACK_OPEN = $_configuration['statistics_database'].".track_e_open";
- $ignore = ignore_user_abort();
- $res=decodeOpenInfos();
-
- if (!is_null($res)){
- $this->assertTrue(is_null($res));
- $this->assertTrue(is_numeric($ignore));
-
- }
- }
- function testextractAgent() {
- $user_agent=$_SERVER['HTTP_USER_AGENT'];
- $list_browsers=array();
- $list_os=array();
- $res=extractAgent($user_agent, $list_browsers, $list_os );
- $this->assertTrue(is_string($res));
-
- }
- function testextractCountry() {
- $remhost= @getHostByAddr($_SERVER['REMOTE_ADDR']);
- $list_countries=array();
- $res=extractCountry($remhost,$list_countries);
- if(!is_null($res))$this->assertTrue(is_string($res));
-
- }
- function testextractProvider() {
- $remhost=@getHostByAddr($_SERVER['REMOTE_ADDR']);
- $res=extractProvider($remhost);
- if(!is_null($res))$this->assertTrue(is_string($res));
-
- }
- function testfillBrowsersTable() {
- global $TABLESTATS_BROWSERS;
- $browsers_array=array();
- $res=fillBrowsersTable($browsers_array);
- if(!is_null($res)) $this->assertTrue(is_array($res));
-
- }
- function testfillCountriesTable() {
- global $TABLESTATS_COUNTRIES,$_configuration;
- $TABLESTATS_COUNTRIES = $_configuration['statistics_database'].".track_c_countries";
- $countries_array=array();
- $res=fillCountriesTable($countries_array);
- $this->assertTrue(is_null($res));
-
- }
- function testfillOsTable() {
- global $TABLESTATS_OS;
- $os_array=array();
- $res=fillOsTable($os_array);
- $this->assertTrue(is_null($res));
-
- }
- function testfillProvidersTable() {
- global $TABLESTATS_PROVIDERS;
- $providers_array=array();
- $res=fillProvidersTable($providers_array);
- $this->assertTrue(is_null($res));
-
- }
- function testfillReferersTable() {
- global $TABLESTATS_REFERERS;
- $referers_array=array();
- $res=fillReferersTable($referers_array);
- $this->assertTrue(is_null($res));
-
- }
- function testloadBrowsers() {
- $res=loadBrowsers();
- $this->assertTrue(is_array($res));
-
- }
- function testloadCountries() {
- global $TABLESTATS_COUNTRIES,$_configuration;
- $TABLESTATS_COUNTRIES = $_configuration['statistics_database'].".track_c_countries";
- $res=loadCountries();
- if (!is_null($res)){
- $this->assertTrue(is_array($res));
- }
-
- }
- function testloadOs() {
- $res=loadOs();
- $this->assertTrue(is_array($res));
-
- }
- }
- ?>
|