File size: 2,196 Bytes
bf8c0ce | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | <?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Tests\Fixtures;
use Piwik\Tests\Framework\Fixture;
/**
* This fixture adds one website and tracks two visits by one visitor.
*/
class VisitsInCurrentYear extends Fixture
{
public $idSite = 1;
public function setUp(): void
{
$this->setUpWebsite();
$this->trackVisits();
}
public function tearDown(): void
{
// empty
}
private function setUpWebsite()
{
if (!self::siteCreated($idSite = 1)) {
self::createWebsite('2018-01-01 15:00:00');
}
}
private function trackVisits()
{
$idSite = $this->idSite;
// Record 1st visit today
$t = self::getTracker($idSite, date('Y-m-d H:i:s'), $defaultInit = true);
$t->setUrl('http://example.org/index.htm?excluded_Parameter=SHOULD_NOT_DISPLAY¶meter=Should display');
$t->setUrlReferrer('http://referrer.com/page.htm?param=valuewith some spaces');
self::checkResponse($t->doTrackPageView('incredible title!'));
// Record 2nd visit 7 days ago
$t = self::getTracker($idSite, date('Y-m-d H:i:s', strtotime('-7days')), $defaultInit = true);
$t->setUrl('http://example.org/index.htm?excluded_Parameter=SHOULD_NOT_DISPLAY¶meter=Should display');
$t->setUrlReferrer('http://referrer.com/page.htm');
self::checkResponse($t->doTrackPageView('incredible!'));
// Record 3rd visit 1 month ago
$t = self::getTracker($idSite, date('Y-m-d H:i:s', strtotime('-1month')), $defaultInit = true);
$t->setUrl('http://example.org/store/purchase.htm');
$t->setUrlReferrer('http://search.yahoo.com/search?p=purchase');
self::checkResponse($t->doTrackPageView('Checkout/Purchasing...'));
// Record 4th visit 1 year ago
$t = self::getTracker($idSite, date('Y-m-d H:i:s', strtotime('-1year')), $defaultInit = true);
$t->setUrl('http://example.org/shop/product.htm');
self::checkResponse($t->doTrackPageView('Visit product'));
}
}
|