Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2015-12-22 22:52:53 +0300
committerThomas Steur <tsteur@users.noreply.github.com>2015-12-22 22:52:53 +0300
commite654274bb78f5b15f439509a7958d76346dfb512 (patch)
treee1b85a232e605036a91a1a4d3e915c3ca289713a /plugins/Live/tests/System
parent9e7da42f55029861be1f05e4fa59214b98758947 (diff)
Remove no longer needed file
Diffstat (limited to 'plugins/Live/tests/System')
-rw-r--r--plugins/Live/tests/System/APICounterTest.php186
1 files changed, 0 insertions, 186 deletions
diff --git a/plugins/Live/tests/System/APICounterTest.php b/plugins/Live/tests/System/APICounterTest.php
deleted file mode 100644
index f957b09608..0000000000
--- a/plugins/Live/tests/System/APICounterTest.php
+++ /dev/null
@@ -1,186 +0,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
- */
-
-namespace Piwik\Plugins\Live\tests\System;
-
-use Piwik\Date;
-use Piwik\Db;
-use Piwik\Plugins\Goals\API as GoalsApi;
-use Piwik\Plugins\Live\API;
-use Piwik\Tests\Framework\Fixture;
-use Piwik\Tests\Framework\Mock\FakeAccess;
-use Piwik\Tests\Framework\TestCase\SystemTestCase;
-
-/**
- * @group Live
- * @group ApiTest
- * @group Api
- * @group Plugins
- */
-class ApiCounterTest extends SystemTestCase
-{
- /**
- * @var API
- */
- private $api;
- private $idSite = 1;
-
- public function setUp()
- {
- parent::setUp();
-
- $this->api = API::getInstance();
- $this->setSuperUser();
- $this->createSite();
- }
-
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage checkUserHasViewAccess Fake exception
- */
- public function test_GetCounters_ShouldFail_IfUserHasNoPermission()
- {
- $this->setAnonymous();
- $this->api->getCounters($this->idSite, 5);
- }
-
- public function test_GetCounters_ShouldReturnZeroForAllCounters_IfThereAreNoVisitsEtc()
- {
- $counters = $this->api->getCounters($this->idSite, 5);
-
- $this->assertEquals($this->buildCounter(0, 0, 0, 0), $counters);
- }
-
- public function test_GetCounters_ShouldOnlyReturnResultsOfLastMinutes()
- {
- $this->trackSomeVisits();
-
- $counters = $this->api->getCounters($this->idSite, 5);
- $this->assertEquals($this->buildCounter(19, 32, 16, 16), $counters);
-
- $counters = $this->api->getCounters($this->idSite, 20);
- $this->assertEquals($this->buildCounter(24, 60, 20, 40), $counters);
-
- $counters = $this->api->getCounters($this->idSite, 0);
- $this->assertEquals($this->buildCounter(0, 0, 0, 0), $counters);
- }
-
- public function test_GetCounters_ShouldHideAllColumnsIfRequested()
- {
- $exampleCounter = $this->buildCounter(0, 0, 0, 0);
- $counters = $this->api->getCounters($this->idSite, 5, false, array(), array_keys($exampleCounter[0]));
- $this->assertEquals(array(array()), $counters);
- }
-
- public function test_GetCounters_ShouldHideSomeColumnsIfRequested()
- {
- $counters = $this->api->getCounters($this->idSite, 20, false, array(), array('visitsConverted', 'visitors'));
- $this->assertEquals(array(array('visits' => 24, 'actions' => 60)), $counters);
- }
-
- public function test_GetCounters_ShouldShowAllColumnsIfRequested()
- {
- $counter = $this->buildCounter(24, 60, 20, 40);
- $counters = $this->api->getCounters($this->idSite, 20, false, array_keys($counter[0]));
- $this->assertEquals($counter, $counters);
- }
-
- public function test_GetCounters_ShouldShowSomeColumnsIfRequested()
- {
- $counters = $this->api->getCounters($this->idSite, 20, false, array('visits', 'actions'));
- $this->assertEquals(array(array('visits' => 24, 'actions' => 60)), $counters);
- }
-
- public function test_GetCounters_ShouldHideColumnIfGivenInShowAndHide()
- {
- $counters = $this->api->getCounters($this->idSite, 20, false, array('visits', 'actions'), array('actions'));
- $this->assertEquals(array(array('visits' => 24)), $counters);
- }
-
- private function trackSomeVisits()
- {
- $nowTimestamp = time();
-
- // use local tracker so mock location provider can be used
- $t = Fixture::getTracker($this->idSite, $nowTimestamp, $defaultInit = true, $useLocal = false);
- $t->enableBulkTracking();
-
- for ($i = 0; $i != 20; ++$i) {
- $t->setForceNewVisit();
- $t->setVisitorId( substr(md5($i * 1000), 0, $t::LENGTH_VISITOR_ID));
-
- $factor = 10;
- if ($i > 15) {
- $factor = 30; // make sure first 15 visits are always within 5 minutes to prevent any random fails
- }
- $time = $nowTimestamp - ($i * $factor);
-
- // first visit -> this one is > 5 minutes and should be ignored in one test
- $date = Date::factory($time - 600);
- $t->setForceVisitDateTime($date->getDatetime());
- $t->setUrl("http://piwik.net/space/quest/iv");
- $t->doTrackPageView("Space Quest XV");
-
- $t->doTrackGoal(1); // this one is > 5 minutes and should be ignored in one test
-
- // second visit
- $date = Date::factory($time - 1);
- $t->setForceVisitDateTime($date->getDatetime());
- $t->setUrl("http://piwik.net/space/quest/iv");
- $t->doTrackPageView("Space Quest XII");
-
- if ($i % 6 == 0) {
- $t->setForceNewVisit(); // to test visitors vs visits
- }
-
- // third visit
- $date = Date::factory($time);
- $t->setForceVisitDateTime($date->getDatetime());
- $t->setUrl("http://piwik.net/grue/$i");
- $t->doTrackPageView('It is pitch black...');
-
- $t->doTrackGoal(2);
- }
-
- $t->doBulkTrack();
- }
-
- private function buildCounter($visits, $actions, $visitors, $visitsConverted)
- {
- return array(array(
- 'visits' => $visits,
- 'actions' => $actions,
- 'visitors' => $visitors,
- 'visitsConverted' => $visitsConverted,
- ));
- }
-
- private function createSite()
- {
- Fixture::createWebsite('2013-01-23 01:23:45');
- GoalsApi::getInstance()->addGoal(1, 'MyName', 'manually', '', 'contains');
- GoalsApi::getInstance()->addGoal(1, 'MyGoal', 'manually', '', 'contains');
- }
-
- private function setSuperUser()
- {
- FakeAccess::$superUser = true;
- }
-
- private function setAnonymous()
- {
- FakeAccess::clearAccess();
- }
-
- public static function provideContainerConfigBeforeClass()
- {
- return array(
- 'Piwik\Access' => new FakeAccess()
- );
- }
-}