public function setUp()
 {
     if (date('G') == 23 || date('G') == 22) {
         $this->markTestSkipped("SKIPPED since it fails around midnight...");
     }
     parent::setUp();
 }
Ejemplo n.º 2
0
 public function setUp()
 {
     parent::setUp();
     $this->cliMulti = new CliMulti();
     $this->authToken = Fixture::getTokenAuth();
     $this->urls = array('getAnswerToLife' => $this->completeUrl('?module=API&method=ExampleAPI.getAnswerToLife&format=JSON'), 'getPiwikVersion' => $this->completeUrl('?module=API&method=API.getPiwikVersion&format=JSON'));
     $this->responses = array('getAnswerToLife' => '{"value":42}', 'getPiwikVersion' => '{"value":"' . Version::VERSION . '"}');
     \Piwik\Common::$isCliMode = true;
 }
 public function setUp()
 {
     parent::setUp();
     $this->defaultApiNotToCall[] = 'Referrers';
     // changes made to SQL dump to test VisitFrequency change the day of week
     $this->defaultApiNotToCall[] = 'VisitTime.getByDayOfWeek';
     // we test VisitFrequency explicitly
     $this->defaultApiNotToCall[] = 'VisitFrequency.get';
 }
Ejemplo n.º 4
0
 /**
  * @return string
  */
 protected static function getPythonBinary()
 {
     if (\Piwik\SettingsServer::isWindows()) {
         return "C:\\Python27\\python.exe";
     }
     if (IntegrationTestCase::isTravisCI()) {
         return 'python2.6';
     }
     return 'python';
 }
 public function getApiForTesting()
 {
     $result = parent::getApiForTesting();
     // Tests that getting a visits summary metric (nb_visits) & a Goal's metric (Goal_revenue)
     // at the same time works.
     $dateTime = '2010-01-03,2010-01-06';
     $columns = 'nb_visits,' . Piwik_Goals::getRecordName('conversion_rate');
     $result[] = array('VisitsSummary.get', array('idSite' => 'all', 'date' => $dateTime, 'periods' => 'range', 'otherRequestParameters' => array('columns' => $columns), 'testSuffix' => '_getMetricsFromDifferentReports'));
     return $result;
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     try {
         self::setUpWebsitesAndGoals();
         self::trackVisits();
     } catch (Exception $e) {
         // Skip whole test suite if an error occurs while setup
         throw new PHPUnit_Framework_SkippedTestSuiteError($e->getMessage());
     }
 }
Ejemplo n.º 7
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     try {
         self::$tokenAuth = self::getTokenAuth();
         self::setUpWebsitesAndGoals();
         self::downloadGeoIpDbs();
         Piwik_UserCountry_LocationProvider::$providers = null;
         Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
         Piwik_UserCountry_LocationProvider::setCurrentProvider('geoip_php');
         self::trackVisits();
     } catch (Exception $e) {
         // Skip whole test suite if an error occurs while setup
         throw new PHPUnit_Framework_SkippedTestSuiteError($e->getMessage());
     }
 }
 public function setUp()
 {
     $sitesManager = Piwik_SitesManager_API::getInstance();
     $goals = Piwik_Goals_API::getInstance();
     // add one thousand sites
     $allIdSites = array();
     for ($i = 0; $i < 1000; ++$i) {
         $allIdSites[] = IntegrationTestCase::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}");
     }
     // add goals to 500 sites
     $idGoals = array();
     foreach ($allIdSites as $idSite) {
         if ($idSite % 2 == 0) {
             $idGoal1 = $goals->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5);
             $idGoal2 = $goals->addGoal($idSite, 'all', 'url', 'http', 'contains');
             $idGoals[$idSite] = array($idGoal1, $idGoal2);
         } else {
             $idGoals[$idSite] = array();
         }
     }
     $urls = array();
     for ($i = 0; $i != 3; ++$i) {
         $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1);
         $title = "page view " . ($i - 1) . " / " . ($i + 1);
         $urls[$url] = $title;
     }
     $visitTimes = array();
     $date = Piwik_Date::factory($this->date);
     for ($i = 0; $i != 4; ++$i) {
         $visitTimes[] = $date->addHour($i)->getDatetime();
     }
     // add 12000 visits (3 visitors with 4 visits each for each site) w/ 3 pageviews each on one day
     foreach ($visitTimes as $visitTime) {
         foreach ($allIdSites as $idSite) {
             for ($visitor = 0; $visitor != 3; ++$visitor) {
                 $t = BenchmarkTestCase::getLocalTracker($this->idSite);
                 $ip = "157.5.6." . ($visitor + 1);
                 $t->setIp($ip);
                 $t->setForceVisitDateTime($visitTime);
                 foreach ($urls as $url => $title) {
                     $t->setUrl($url);
                     $t->doTrackPageView($title);
                 }
             }
         }
     }
 }
 public function setUp()
 {
     // add one site
     IntegrationTestCase::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
     // add two goals
     $goals = Piwik_Goals_API::getInstance();
     $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
     $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains');
     $urls = array();
     for ($i = 0; $i != 3; ++$i) {
         $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1);
         $title = "page view " . ($i - 1) . " / " . ($i + 1);
         $urls[$url] = $title;
     }
     $visitTimes = array();
     $date = Piwik_Date::factory($this->date);
     for ($month = 0; $month != 12; ++$month) {
         for ($day = 0; $day != 25; ++$day) {
             $hour = $time * 31 / 60.0;
             $visitTimes[] = $date->addPeriod($month, 'MONTH')->addDay($day)->getDatetime();
         }
     }
     // add 12,000 visits (1 visit a day from 40 visitors for 25 days of every month) w/ 3 pageviews each
     foreach ($visitTimes as $visitTime) {
         for ($visitor = 0; $visitor != 40; ++$visitor) {
             $t = BenchmarkTestCase::getLocalTracker($this->idSite);
             $ip = "157.5.6." . ($visitor + 1);
             $t->setIp($ip);
             $t->setForceVisitDateTime($visitTime);
             foreach ($urls as $url => $title) {
                 $t->setUrl($url);
                 $t->doTrackPageView($title);
             }
         }
     }
 }
Ejemplo n.º 10
0
 public static function tearDownAfterClass()
 {
     // only drop the database if PIWIK_BENCHMARK_DATABASE isn't set
     $dropDatabase = empty($GLOBALS['PIWIK_BENCHMARK_DATABASE']);
     parent::_tearDownAfterClass($dropDatabase);
 }
 public function setUp()
 {
     parent::setUp();
     self::$driver->get(wordpress('/wp-admin/plugins.php'));
 }
Ejemplo n.º 12
0
 protected function tearDown()
 {
     parent::tearDown();
 }
Ejemplo n.º 13
0
 public function setUp()
 {
     parent::setUp();
     $this->model = new Model();
 }
 public function setUp()
 {
     parent::setUp();
     $this->twitter = m::mock(Twitter::class);
 }
Ejemplo n.º 15
0
 /**
  * Sets a list of API methods to not call during the test
  *
  * @param string $apiNotToCall eg. 'ExampleAPI.getPiwikVersion'
  *
  * @return void
  */
 protected static function setApiNotToCall($apiNotToCall)
 {
     if (!is_array($apiNotToCall)) {
         $apiNotToCall = array($apiNotToCall);
     }
     self::$apiNotToCall = $apiNotToCall;
 }
Ejemplo n.º 16
0
 public function setUp()
 {
     parent::setUp();
 }
Ejemplo n.º 17
0
 public static function setUpBeforeClass()
 {
     self::$driver = RemoteWebDriver::createBySessionId($GLOBALS['global_session_id'], $GLOBALS['global_webdriver_host']);
 }
 public static function setUpBeforeClass()
 {
     self::$fixture->dateTime = Date::factory('today')->getDateTime();
     parent::setUpBeforeClass();
 }
Ejemplo n.º 19
0
 public function tearDown()
 {
     parent::tearDown();
     Manager::getInstance()->deleteAll();
     Option::clearCache();
     Site::clearCache();
     Cache::deleteTrackerCache();
     ArchiveTableCreator::clear();
     $tempTableName = Common::prefixTable(LogDataPurger::TEMP_TABLE_NAME);
     Db::query("DROP TABLE IF EXISTS " . $tempTableName);
 }
Ejemplo n.º 20
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 = Piwik_Date::factory(self::$dateTime);
     self::createWebsite('2012-01-01', $ecommerce = 1);
     $idGoal = Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'match all', 'url', 'http', 'contains');
     $t = IntegrationTestCase::getTracker(self::$idSite, $start, $defaultInit = true);
     $t->enableBulkTracking();
     $t->setTokenAuth(IntegrationTestCase::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->setUrl("http://whatever.com/42/{$daysAgo}");
         $t->doTrackPageView('Second page view');
         $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);
     }
     $t->doBulkTrack();
 }
Ejemplo n.º 21
0
 public static function tearDownAfterClass()
 {
     self::unsetMockLocationProvider();
     parent::tearDownAfterClass();
 }
 public function tear_down()
 {
     parent::tear_down();
     clear_settings();
 }
 public function setUp()
 {
     parent::setUp();
     self::$driver->get(wordpress('/wp-admin/options-media.php'));
 }
 public function setUp()
 {
     parent::setUp();
     $this->repository = new StatusRepository();
 }
Ejemplo n.º 25
0
 public function setUp()
 {
     parent::setUp();
     $this->api = API::getInstance();
 }
 public static function set_up_before_class()
 {
     self::$driver = RemoteWebDriver::createBySessionId($GLOBALS['global_session_id'], $GLOBALS['global_webdriver_host']);
     self::$db = new mysqli(getenv('HOST'), 'root', getenv('MYSQL_PWD'), getenv('WORDPRESS_DATABASE'));
 }
Ejemplo n.º 27
0
 public function tearDown()
 {
     parent::tearDownAfterClass();
 }
 public function setUp()
 {
     parent::setUp();
     App::build(['Controller' => [CakePlugin::path('Shim') . 'Test' . DS . 'test_app' . DS . 'Controller' . DS], 'Model' => [CakePlugin::path('Shim') . 'Test' . DS . 'test_app' . DS . 'Model' . DS], 'View' => [CakePlugin::path('Shim') . 'Test' . DS . 'test_app' . DS . 'View' . DS]], App::RESET);
 }
Ejemplo n.º 29
0
 public function tearDown()
 {
     parent::tearDown();
     // reset that value after the test
     Piwik_API_Proxy::getInstance()->setHideIgnoredFunctions(true);
 }
Ejemplo n.º 30
0
<?php

/**
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */
/**
 * @deprecated since 2.8.0 extend \Piwik\Tests\Framework\TestCase\SystemTestCase instead
 */
class IntegrationTestCase extends \Piwik\Tests\Framework\TestCase\SystemTestCase
{
    public static function setUpBeforeClass()
    {
        \Piwik\Log::debug('\\IntegrationTestCase is deprecated since 2.8.0 extend \\Piwik\\Tests\\Framework\\TestCase\\SystemTestCase instead');
        parent::setUpBeforeClass();
    }
}
IntegrationTestCase::$fixture = new \Piwik\Tests\Framework\Fixture();