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-10 19:52:38 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-08-10 19:52:38 +0300
commit026939b67d0003c1dca2454287d061c130e5aba4 (patch)
tree560eac15f61b08ae1cf07fffba993eaf7192bd64 /tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php
parent35c5cb9b94461e28209ae13851963c7633a10f82 (diff)
added a test
Diffstat (limited to 'tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php')
-rw-r--r--tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php99
1 files changed, 99 insertions, 0 deletions
diff --git a/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php b/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php
new file mode 100644
index 0000000000..df68b1c1bb
--- /dev/null
+++ b/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php
@@ -0,0 +1,99 @@
+<?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\Integration\DataAccess;
+
+use Piwik\ArchiveProcessor\Parameters;
+use Piwik\DataAccess\LogAggregator;
+use Piwik\Date;
+use Piwik\Period;
+use Piwik\Segment;
+use Piwik\Site;
+use Piwik\Tests\Framework\Fixture;
+use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
+
+/**
+ * @group Core
+ * @group DataAccess
+ * @group LogAggregator
+ * @group LogAggregatorTest
+ */
+class LogAggregatorTest extends IntegrationTestCase
+{
+ /**
+ * @var LogAggregator
+ */
+ private $logAggregator;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $idSite = 1;
+
+ if (!Fixture::siteCreated($idSite)) {
+ Fixture::createWebsite('2014-01-01 00:00:00');
+ }
+
+ $site = new Site($idSite);
+ $date = Date::factory('2012-01-01');
+ $period = Period\Factory::build('month', $date);
+ $segment = new Segment('', array($site->getId()));
+
+
+ $params = new Parameters($site, $period, $segment);
+ $this->logAggregator = new LogAggregator($params);
+ }
+
+ public function test_generateQuery()
+ {
+ $query = $this->logAggregator->generateQuery('test, test2', 'log_visit', '1=1', false, '5');
+
+ $expected = array(
+ 'sql' => '
+ SELECT
+ test, test2
+ FROM
+ log_visit AS log_visit
+ WHERE
+ 1=1
+ ORDER BY
+ 5',
+ 'bind' => Array (
+ 0 => '2012-01-01 00:00:00',
+ 1 => '2012-01-31 23:59:59',
+ 2 => 1
+ )
+ );
+ $this->assertSame($expected, $query);
+ }
+
+ public function test_generateQuery_WithQueryHint_ShouldAddQueryHintAsComment()
+ {
+ $this->logAggregator->setQueryOriginHint('MyPluginName');
+ $query = $this->logAggregator->generateQuery('test, test2', 'log_visit', '1=1', false, '5');
+
+ $expected = array(
+ 'sql' => 'SELECT /* MyPluginName */
+ test, test2
+ FROM
+ log_visit AS log_visit
+ WHERE
+ 1=1
+ ORDER BY
+ 5',
+ 'bind' => Array (
+ 0 => '2012-01-01 00:00:00',
+ 1 => '2012-01-31 23:59:59',
+ 2 => 1
+ )
+ );
+ $this->assertSame($expected, $query);
+ }
+
+}