diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-09-18 13:38:19 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-09-18 13:38:19 +0400 |
commit | aad5f3369e65007c6e63ab8bcc2a2b4581d3023b (patch) | |
tree | 41bc86d1a0dd9e1f5e2f15c52db251932251c0e1 /plugins/Contents/tests/Fixtures | |
parent | 0918324ad104e99fc13827ddfb31b7ea25c6511a (diff) |
refs #4996 looks like the setup fixture requires a capital F
Diffstat (limited to 'plugins/Contents/tests/Fixtures')
-rw-r--r-- | plugins/Contents/tests/Fixtures/TwoVisitsWithContents.php | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/plugins/Contents/tests/Fixtures/TwoVisitsWithContents.php b/plugins/Contents/tests/Fixtures/TwoVisitsWithContents.php new file mode 100644 index 0000000000..e99bef0609 --- /dev/null +++ b/plugins/Contents/tests/Fixtures/TwoVisitsWithContents.php @@ -0,0 +1,93 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ +namespace Piwik\Plugins\Contents\tests\fixtures; + +use Piwik\Date; +use Piwik\Plugins\Goals\API as APIGoals; +use Piwik\Tests\Fixture; +use PiwikTracker; + +/** + * Tracks contents + */ +class TwoVisitsWithContents extends Fixture +{ + public $dateTime = '2010-01-03 11:22:33'; + public $idSite = 1; + public $idGoal1 = 1; + + public function setUp() + { + $this->setUpWebsitesAndGoals(); + $this->trackVisits(); + } + + private function setUpWebsitesAndGoals() + { + // tests run in UTC, the Tracker in UTC + if (!self::siteCreated($idSite = 1)) { + self::createWebsite($this->dateTime); + } + + if (!self::goalExists($idSite = 1, $idGoal = 1)) { + // These two goals are to check contents don't trigger for URL or Title matching + APIGoals::getInstance()->addGoal($this->idSite, 'triggered js', 'url', 'webradio', 'contains'); + APIGoals::getInstance()->addGoal($this->idSite, 'triggered js', 'title', 'Music', 'contains'); + } + } + + public function trackVisits() + { + $uselocal = false; + $vis = self::getTracker($this->idSite, $this->dateTime, $useDefault = true, $uselocal); + + $this->trackContentImpressionsAndInteractions($vis); + + $this->dateTime = Date::factory($this->dateTime)->addHour(0.5); + $vis2 = self::getTracker($this->idSite, $this->dateTime, $useDefault = true, $uselocal); + $vis2->setIp('111.1.1.1'); + $vis2->setPlugins($flash = false, $java = false, $director = true); + + $this->trackContentImpressionsAndInteractions($vis2); + } + + private function moveTimeForward(PiwikTracker $vis, $minutes) + { + $hour = $minutes / 60; + $vis->setForceVisitDateTime(Date::factory($this->dateTime)->addHour($hour)->getDatetime()); + } + + protected function trackContentImpressionsAndInteractions(PiwikTracker $vis) + { + $vis->setUrl('http://www.example.org/page'); + $vis->setGenerationTime(333); + self::checkResponse($vis->doTrackPageView('Ads')); + + self::checkResponse($vis->doTrackContentImpression('ImageAd')); + self::checkResponse($vis->doTrackContentImpression('ImageAd', '')); + + $this->moveTimeForward($vis, 2); + self::checkResponse($vis->doTrackContentImpression('ImageAd', '/path/ad.jpg', 'http://www.example.com')); + self::checkResponse($vis->doTrackContentImpression('ImageAd', '/path/ad2.jpg', 'http://www.example.com')); + self::checkResponse($vis->doTrackContentInteraction('submit', 'ImageAd', '/path/ad.jpg', 'http://www.example.com')); + $this->moveTimeForward($vis, 3); + self::checkResponse($vis->doTrackContentImpression('Text Ad', 'Click to download Piwik now', 'http://piwik.org/download')); + self::checkResponse($vis->doTrackContentImpression('Text Ad', 'Click NOW', 'http://piwik.org/')); + self::checkResponse($vis->doTrackContentInteraction('click', 'Text Ad', 'Click to download Piwik now', 'http://piwik.org/download')); + self::checkResponse($vis->doTrackContentInteraction('click', 'Text Ad', 'Click NOW', 'http://piwik.org/download')); + $this->moveTimeForward($vis, 4); + self::checkResponse($vis->doTrackContentImpression('Text Ad', 'Click to download Piwik now', '')); + + $this->moveTimeForward($vis, 4.5); + self::checkResponse($vis->doTrackContentImpression('Video Ad', 'movie.mov')); + } + + public function tearDown() + { + } +}
\ No newline at end of file |