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>2016-04-12 07:17:09 +0300
committerThomas Steur <thomas.steur@gmail.com>2016-04-12 08:49:11 +0300
commit168ac84b28174442220f84d78a6b086192552735 (patch)
tree8be6621d00f134465a84992b918e8c5cfb49de53 /plugins/Insights
parente3677583a96ac5e87f5a22ef8685f7c36cf80c88 (diff)
Make tests fast again
Diffstat (limited to 'plugins/Insights')
-rw-r--r--plugins/Insights/API.php3
-rw-r--r--plugins/Insights/Model.php12
-rw-r--r--plugins/Insights/tests/Integration/ModelTest.php3
3 files changed, 13 insertions, 5 deletions
diff --git a/plugins/Insights/API.php b/plugins/Insights/API.php
index 4b3228ffc2..23e9bc23f5 100644
--- a/plugins/Insights/API.php
+++ b/plugins/Insights/API.php
@@ -81,8 +81,7 @@ class API extends \Piwik\Plugin\API
Piwik::checkUserHasSomeViewAccess();
try {
- $model = new Model();
- $lastDate = $model->getLastDate($date, $period, 1);
+ $lastDate = $this->model->getLastDate($date, $period, 1);
} catch (\Exception $e) {
return false;
}
diff --git a/plugins/Insights/Model.php b/plugins/Insights/Model.php
index b8c4957e55..7f1d906c16 100644
--- a/plugins/Insights/Model.php
+++ b/plugins/Insights/Model.php
@@ -21,6 +21,15 @@ use Piwik\Plugins\VisitsSummary\API as VisitsSummaryAPI;
*/
class Model
{
+ /**
+ * @var ProcessedReport
+ */
+ private $processedReport;
+
+ public function __construct(ProcessedReport $processedReport)
+ {
+ $this->processedReport = $processedReport;
+ }
public function requestReport($idSite, $period, $date, $reportUniqueId, $metric, $segment)
{
@@ -112,8 +121,7 @@ class Model
public function getReportByUniqueId($idSite, $reportUniqueId)
{
- $processedReport = new ProcessedReport();
- $report = $processedReport->getReportMetadataByUniqueId($idSite, $reportUniqueId);
+ $report = $this->processedReport->getReportMetadataByUniqueId($idSite, $reportUniqueId);
return $report;
}
diff --git a/plugins/Insights/tests/Integration/ModelTest.php b/plugins/Insights/tests/Integration/ModelTest.php
index 065e4bcc4d..dfa9c6952c 100644
--- a/plugins/Insights/tests/Integration/ModelTest.php
+++ b/plugins/Insights/tests/Integration/ModelTest.php
@@ -8,6 +8,7 @@
namespace Piwik\Plugins\Insights\tests\Integration;
+use Piwik\Container\StaticContainer;
use Piwik\DataTable;
use Piwik\Plugins\Insights\Model;
use Piwik\Plugins\Insights\tests\Fixtures\SomeVisitsDifferentPathsOnTwoDays;
@@ -35,7 +36,7 @@ class ModelTest extends SystemTestCase
{
parent::setUp();
- $this->model = new Model();
+ $this->model = StaticContainer::getContainer()->make('Piwik\Plugins\Insights\Model');
}
public function test_requestReport_shouldReturnTheDataTableOfTheReport_AndContainReportTotals()