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 'tests/PHPUnit/Unit/DataTableTest.php')
-rw-r--r--tests/PHPUnit/Unit/DataTableTest.php37
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/PHPUnit/Unit/DataTableTest.php b/tests/PHPUnit/Unit/DataTableTest.php
index 424fce0186..fbc1f5adee 100644
--- a/tests/PHPUnit/Unit/DataTableTest.php
+++ b/tests/PHPUnit/Unit/DataTableTest.php
@@ -12,6 +12,7 @@ use Piwik\Common;
use Piwik\DataTable\Manager;
use Piwik\DataTable\Row;
use Piwik\DataTable;
+use Piwik\Date;
use Piwik\Timer;
use Symfony\Component\VarDumper\Cloner\Data;
@@ -672,7 +673,9 @@ class DataTableTest extends \PHPUnit_Framework_TestCase
$subtableId = $row[Row::DATATABLE_ASSOCIATED];
- if ($row[Row::COLUMNS]['label'] === DataTable::LABEL_SUMMARY_ROW) {
+ if ($row[Row::COLUMNS]['label'] === DataTable::LABEL_SUMMARY_ROW
+ || $row[Row::COLUMNS]['label'] === DataTable::LABEL_ARCHIVED_METADATA_ROW
+ ) {
$this->assertNull($subtableId);
} else {
@@ -713,6 +716,38 @@ class DataTableTest extends \PHPUnit_Framework_TestCase
), $tables);
}
+ public function test_serializationOfDataTableMetadata()
+ {
+ $table = new DataTable();
+ $table->addRow(new Row([
+ Row::COLUMNS => ['label' => 'abc', 'nb_visits' => 5],
+ ]));
+ $table->setAllTableMetadata([
+ 'str' => 'str value',
+ 'int' => 5,
+ 'float' => 3.65,
+ 'bool' => true,
+ 'object' => Date::today(),
+ ]);
+
+ $serialized = $table->getSerialized();
+
+ $newTable = DataTable::fromSerializedArray(reset($serialized));
+
+ $this->assertEquals([
+ new Row([
+ Row::COLUMNS => ['label' => 'abc', 'nb_visits' => 5],
+ ]),
+ ], $newTable->getRows());
+
+ $this->assertEquals([
+ 'str' => 'str value',
+ 'int' => 5,
+ 'float' => 3.65,
+ 'bool' => true,
+ ], $newTable->getAllTableMetadata());
+ }
+
private function addManyRows(DataTable $table, $numRows)
{
for ($i = 0; $i < $numRows; $i++) {