insertHit(FS_COMMIT_IMMEDIATE, $this->hit("2008-01-02 00:00:00",$ip[0], "1",$urls[0],$urls[1], $useragents[0])); $this->assertTrue($res, "Failed : $res"); $res = $this->insertHit(FS_COMMIT_IMMEDIATE, $this->hit("2008-01-03 00:00:00",$ip[0], "1",$urls[0],$urls[1], $useragents[0])); $this->assertTrue($res, "Failed : $res"); $res = $this->insertHit(FS_COMMIT_IMMEDIATE, $this->hit("2008-01-04 00:00:00",$ip[0], "1",$urls[0],$urls[1], $useragents[1])); $this->assertTrue($res, "Failed : $res"); $this->assertEquals(array("useragent 1","useragent 2",), $this->transform_array(fs_get_useragents(1000, 1), create_function('$i','return $i["useragent"];'))); $stats_before = $this->getStats(); // archiving is not supposed to change those state. // Don't archive anything. fs_archive_old_data(strtotime("2008-01-02 00:00:00"), 100); $res = fs_getentries(); $this->assertFalse($res == false, "getentries failed"); $this->assertEquals(3, count($res)); $this->assertEquals($stats_before, $this->getStats()); // archive one day. fs_archive_old_data(strtotime("2008-01-03 00:00:00"), 100); $res = fs_getentries(); $this->assertFalse($res == false, "getentries failed"); $this->assertEquals(2, count($res)); $this->assertEquals($stats_before, $this->getStats()); $useragents_after_archiving = fs_get_useragent_views_range(1, true, strtotime("2008-01-02 00:00:00"),strtotime("2008-01-04 00:00:01")); $this->assertEquals(array("useragent 1","useragent 2",), $this->transform_array($useragents_after_archiving, create_function('$i','return $i["useragent"];'))); } function transform_array($array, $func) { $res = array(); foreach($array as $a) { $res[] = $func($a); } return $res; } function getStats() { return array ( "countries" => fs_get_country_codes(1000, 1), "page_views_ever" => fs_get_hit_count(null, 1), "visitors_views_ever" => fs_get_unique_hit_count(null, 1), "recent_referrers" => fs_get_recent_referers(1000, null, 1), "popular_pages" => fs_get_popular_pages(1000, null, 1), "user_agents" => fs_get_useragents(1000, 1), ); } } ?>