Example #1
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     self::_addLogData();
     self::_addReportData();
     self::$dbData = self::getDbTablesWithData();
 }
Example #2
0
 protected static function _addLogData()
 {
     // tracks visits on the following days:
     // - 2012-01-09
     // - 2012-01-14
     // - 2012-01-19
     // - 2012-01-24 <--- everything before this date is to be purged
     // - 2012-01-29
     // - 2012-02-03
     // - 2012-02-08
     // - 2012-02-13
     // - 2012-02-18
     // - 2012-02-23
     // - 2012-02-28
     // 6 visits in feb, 5 in jan
     // following actions are created:
     // - 'First page view'
     // - 'Second page view'
     // - 'SKU2'
     // - 'Canon SLR'
     // - 'Electronics & Cameras'
     // - for every visit (11 visits total):
     //   - http://whatever.com/_{$daysSinceLastVisit}
     //   - http://whatever.com/42/{$daysSinceLastVisit}
     $start = Date::factory(self::$dateTime);
     self::$idSite = Fixture::createWebsite('2012-01-01', $ecommerce = 1);
     $idGoal = APIGoals::getInstance()->addGoal(self::$idSite, 'match all', 'url', 'http', 'contains');
     $t = Fixture::getTracker(self::$idSite, $start, $defaultInit = true);
     $t->enableBulkTracking();
     $t->setTokenAuth(Fixture::getTokenAuth());
     for ($daysAgo = self::$daysAgoStart; $daysAgo >= 0; $daysAgo -= 5) {
         $dateTime = $start->subDay($daysAgo)->toString();
         $t->setForceVisitDateTime($dateTime);
         $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)');
         // use $daysAgo to make sure new actions are created for every day and aren't used again.
         // when deleting visits, some of these actions will no longer be referenced in the DB.
         $t->setUrl("http://whatever.com/_{$daysAgo}");
         $t->doTrackPageView('First page view');
         $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.05));
         $t->setUrl("http://whatever.com/42/{$daysAgo}");
         $t->doTrackPageView('Second page view');
         $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.1));
         $t->setUrl("http://whatever.com/event");
         $t->doTrackEvent('Event action', 'event cat', 'daysAgo=' . $daysAgo, 1000);
         $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2));
         $t->addEcommerceItem($sku = 'SKU2', $name = 'Canon SLR', $category = 'Electronics & Cameras', $price = 1500, $quantity = 1);
         $t->doTrackEcommerceOrder($orderId = '937nsjusu ' . $dateTime, $grandTotal = 1111.11, $subTotal = 1000, $tax = 111, $shipping = 0.11, $discount = 666);
     }
     Fixture::checkBulkTrackingResponse($t->doBulkTrack());
 }