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:
Diffstat (limited to 'plugins/Insights/tests/Unit/BaseUnitTest.php')
-rw-r--r--plugins/Insights/tests/Unit/BaseUnitTest.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/Insights/tests/Unit/BaseUnitTest.php b/plugins/Insights/tests/Unit/BaseUnitTest.php
new file mode 100644
index 0000000000..97c2c78580
--- /dev/null
+++ b/plugins/Insights/tests/Unit/BaseUnitTest.php
@@ -0,0 +1,50 @@
+<?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\Insights\tests;
+
+use Piwik\DataTable;
+use Piwik\DataTable\Row;
+
+/**
+ * Abstract class because it avoids it being picked up as a test case
+ * (which would trigger warning because it has no test)
+ *
+ * @group Insights
+ * @group Unit
+ * @group Core
+ */
+abstract class BaseUnitTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var DataTable
+ */
+ protected $table;
+
+ protected function assertOrder($expectedOrder)
+ {
+ $this->assertEquals($expectedOrder, $this->table->getColumn('label'));
+ $this->assertEquals(count($expectedOrder), $this->table->getRowsCount());
+ }
+
+ protected function assertColumnValues($rowsWithValues)
+ {
+ $index = 0;
+ foreach ($this->table->getRows() as $row) {
+ $rowToCheck = $rowsWithValues[$index];
+ foreach ($rowToCheck as $columnToCheck => $expectedValue) {
+ $actualValue = $row->getColumn($columnToCheck);
+ $this->assertEquals($expectedValue, $actualValue, "$columnToCheck in row $index does not match assumed $actualValue is $expectedValue");
+ }
+ $index++;
+ }
+
+ $this->assertEquals(count($rowsWithValues), $this->table->getRowsCount());
+ }
+
+}