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 <thomas.steur@gmail.com>2015-08-12 18:23:38 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-08-21 12:48:31 +0300
commit500202b12aa8879c7deb09035792c9aab99f9da2 (patch)
tree47421d728fdb61a5ed09c1a0e943b9a074184e1f /tests/PHPUnit/System/RawLogDaoTest.php
parentaa8591b6e58fa5e9964cacc405493abe7bb80eaf (diff)
refs #8066 faster query to find websites with traffic since last successful archiving
Diffstat (limited to 'tests/PHPUnit/System/RawLogDaoTest.php')
-rw-r--r--tests/PHPUnit/System/RawLogDaoTest.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/PHPUnit/System/RawLogDaoTest.php b/tests/PHPUnit/System/RawLogDaoTest.php
new file mode 100644
index 0000000000..e0210467e2
--- /dev/null
+++ b/tests/PHPUnit/System/RawLogDaoTest.php
@@ -0,0 +1,68 @@
+<?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\Tests\System;
+
+use Piwik\DataAccess\RawLogDao;
+use Piwik\Tests\Framework\Fixture;
+use Piwik\Tests\Framework\TestCase\SystemTestCase;
+
+/**
+ * @group Core
+ * @group RawLogDao
+ * @group RawLogDaoTest
+ */
+class RawLogDaoTest extends SystemTestCase
+{
+ /**
+ * @var RawLogDao
+ */
+ private $dao;
+
+ private $idSite = 1;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ if (!Fixture::siteCreated($this->idSite)) {
+ Fixture::createWebsite('2010-00-00 00:00:00');
+ }
+
+ $this->dao = new RawLogDao();
+ }
+
+ /**
+ * @dataProvider getVisitsInTimeFrameData
+ */
+ public function test_hasSiteVisitsInTimeframe_shouldDetectWhetherThereAreVisitsInCertainTimeframe($from, $to, $idSite, $expectedHasVisits)
+ {
+ Fixture::getTracker($this->idSite, '2015-01-25 05:35:27')->doTrackPageView('/test');
+
+ $hasVisits = $this->dao->hasSiteVisitsBetweenTimeframe($from, $to, $idSite);
+ $this->assertSame($expectedHasVisits, $hasVisits);
+ }
+
+ public function getVisitsInTimeFrameData()
+ {
+ return array(
+ array($from = '2015-01-25 05:35:26', $to = '2015-01-25 05:35:27', $this->idSite, $hasVisits = false), // there is no second "between" the timeframe so cannot have visits
+ array($from = '2015-01-25 05:35:27', $to = '2015-01-25 05:35:28', $this->idSite, $hasVisits = false), // there is no second "between" the timeframe so cannot have visits
+ array($from = '2015-01-25 05:35:26', $to = '2015-01-25 05:35:28', $this->idSite, $hasVisits = true), // only one sec difference between from and to
+ array($from = '2015-01-25 05:35:26', $to = '2015-01-26 05:35:27', $this->idSite, $hasVisits = true),
+ array($from = '2015-01-24 05:35:26', $to = '2015-01-26 05:35:27', $this->idSite, $hasVisits = true),
+ array($from = '2015-01-25 05:35:26', $to = '2015-01-25 05:35:27', $idSite = 2, $hasVisits = false), // no because idSite does not match
+ array($from = '2015-01-24 05:35:26', $to = '2015-01-25 05:35:27', $idSite = 2, $hasVisits = false), // ...
+ array($from = '2015-01-25 05:35:26', $to = '2015-01-26 05:35:27', $idSite = 2, $hasVisits = false), // ...
+ array($from = '2015-01-24 05:35:26', $to = '2015-01-26 05:35:27', $idSite = 2, $hasVisits = false), // ... no because not matching idsite
+ array($from = '2015-01-24 05:35:26', $to = '2015-01-25 05:35:26', $this->idSite, $hasVisits = false), // time of visit is later
+ array($from = '2015-01-25 05:35:28', $to = '2015-01-27 05:35:27', $this->idSite, $hasVisits = false), // time of visit is earlier
+ );
+ }
+
+}