diff options
author | Kate Butler <kate@innocraft.com> | 2019-07-02 13:33:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-02 13:33:55 +0300 |
commit | e4cb4463dac83a996202e6e1fa82d1895557acf8 (patch) | |
tree | 85de25d64c3a27d1e53994d41d9275462e2a75ba /plugins | |
parent | 152f51354629e4e0ea00711e0b737b223bf1df5f (diff) |
Gracefully handle case when row evolution has no data (#14562)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/API/RowEvolution.php | 4 | ||||
-rw-r--r-- | plugins/API/tests/Integration/RowEvolutionTest.php | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/plugins/API/RowEvolution.php b/plugins/API/RowEvolution.php index 41c75bffde..9fd489f7e4 100644 --- a/plugins/API/RowEvolution.php +++ b/plugins/API/RowEvolution.php @@ -55,6 +55,10 @@ class RowEvolution $dataTable = $this->loadRowEvolutionDataFromAPI($metadata, $idSite, $period, $date, $apiModule, $apiAction, $labels, $segment, $apiParameters); + if (empty($dataTable->getDataTables())) { + return array(); + } + if (empty($labels)) { $labels = $this->getLabelsFromDataTable($dataTable, $labels); $dataTable = $this->enrichRowAddMetadataLabelIndex($labels, $dataTable); diff --git a/plugins/API/tests/Integration/RowEvolutionTest.php b/plugins/API/tests/Integration/RowEvolutionTest.php index b796562cac..d96bb0efac 100644 --- a/plugins/API/tests/Integration/RowEvolutionTest.php +++ b/plugins/API/tests/Integration/RowEvolutionTest.php @@ -43,4 +43,10 @@ class RowEvolutionTest extends IntegrationTestCase $this->assertNotEmpty($table); } + public function test_getRowEvolution_shouldReturnEmptyArray_IfNoData() + { + $rowEvolution = new RowEvolution(); + $table = $rowEvolution->getRowEvolution(1, 'day', 'last7', 'Actions', 'getSiteSearchCategories'); + $this->assertEquals(array(), $table); + } } |