diff options
author | mattab <matthieu.aubry@gmail.com> | 2015-03-19 08:53:04 +0300 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2015-03-19 08:53:04 +0300 |
commit | d92175983c26a964e909c6463a88073e5540ada7 (patch) | |
tree | 80134e64baea9ff5587906b971767545a472874a | |
parent | 9c1fb09e53166278682eed8d7db0f9c65a7a79eb (diff) |
Fix unit tests
-rw-r--r-- | plugins/SegmentEditor/Model.php | 17 | ||||
-rw-r--r-- | tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php | 3 |
2 files changed, 11 insertions, 9 deletions
diff --git a/plugins/SegmentEditor/Model.php b/plugins/SegmentEditor/Model.php index 2192e3ca58..7f312557f9 100644 --- a/plugins/SegmentEditor/Model.php +++ b/plugins/SegmentEditor/Model.php @@ -18,11 +18,10 @@ use Piwik\DbHelper; class Model { private static $rawPrefix = 'segment'; - private $table; - public function __construct() + protected function getTable() { - $this->table = Common::prefixTable(self::$rawPrefix); + return Common::prefixTable(self::$rawPrefix); } /** @@ -33,7 +32,7 @@ class Model */ public function getAllSegmentsAndIgnoreVisibility() { - $sql = "SELECT * FROM " . $this->table . " WHERE deleted = 0"; + $sql = "SELECT * FROM " . $this->getTable() . " WHERE deleted = 0"; $segments = $this->getDb()->fetchAll($sql); @@ -102,7 +101,7 @@ class Model public function deleteSegment($idSegment) { $db = $this->getDb(); - $db->delete($this->table, 'idsegment = ' . (int) $idSegment); + $db->delete($this->getTable(), 'idsegment = ' . (int) $idSegment); } public function updateSegment($idSegment, $segment) @@ -110,7 +109,7 @@ class Model $idSegment = (int) $idSegment; $db = $this->getDb(); - $db->update($this->table, $segment, "idsegment = $idSegment"); + $db->update($this->getTable(), $segment, "idsegment = $idSegment"); return true; } @@ -118,7 +117,7 @@ class Model public function createSegment($segment) { $db = $this->getDb(); - $db->insert($this->table, $segment); + $db->insert($this->getTable(), $segment); $id = $db->lastInsertId(); return $id; @@ -127,7 +126,7 @@ class Model public function getSegment($idSegment) { $db = $this->getDb(); - $segment = $db->fetchRow("SELECT * FROM " . $this->table . " WHERE idsegment = ?", $idSegment); + $segment = $db->fetchRow("SELECT * FROM " . $this->getTable() . " WHERE idsegment = ?", $idSegment); return $segment; } @@ -139,7 +138,7 @@ class Model private function buildQuerySortedByName($where) { - return "SELECT * FROM " . $this->table . " WHERE $where ORDER BY name ASC"; + return "SELECT * FROM " . $this->getTable() . " WHERE $where ORDER BY name ASC"; } public static function install() diff --git a/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php b/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php index 0aa8533744..575b7b0c2f 100644 --- a/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php +++ b/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php @@ -7,6 +7,7 @@ */ namespace Piwik\Tests\Unit\CronArchive; +use Piwik\Config; use Piwik\Date; use Piwik\CronArchive\SegmentArchivingRequestUrlProvider; @@ -21,6 +22,8 @@ class SegmentArchivingRequestUrlProviderTest extends \PHPUnit_Framework_TestCase public function setUp() { + Config::getInstance()->General['enabled_periods_API'] = 'day,week,month,year,range'; + $this->mockSegmentEntries = array( array( 'ts_created' => '2014-01-01', |