From 395ae80186ec4575b4d3c39ba3f5398759988e96 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Tue, 7 Jun 2022 11:41:57 +0200 Subject: [PATCH] Tests: Add remove Pane/Dashlet test cases --- .../Icinga/Web/Dashboard/DashletTest.php | 57 +++++++++++++++++++ .../library/Icinga/Web/Dashboard/PaneTest.php | 47 +++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/test/php/library/Icinga/Web/Dashboard/DashletTest.php b/test/php/library/Icinga/Web/Dashboard/DashletTest.php index 2ff10178c..f60a51c0c 100644 --- a/test/php/library/Icinga/Web/Dashboard/DashletTest.php +++ b/test/php/library/Icinga/Web/Dashboard/DashletTest.php @@ -200,4 +200,61 @@ class DashletTest extends BaseDashboardTestCase $default = new Pane('Test Pane'); $default->manageEntry($this->getTestDashlet(), $this->getTestHome()); } + + public function testWhetherRemoveEntryRemovesExpectedDashletEntry() + { + $home = $this->getTestHome(); + $this->dashboard->manageEntry($home); + + $pane = new Pane('Test Pane'); + $home->manageEntry($pane); + + $pane->manageEntry($this->getTestDashlet()); + + $this->dashboard->load(self::TEST_HOME, $pane->getName()); + + $home = $this->dashboard->getActiveHome(); + $pane = $home->getActivePane(); + + $pane->removeEntry(self::TEST_DASHLET); + + $this->dashboard->load(); + + $home = $this->dashboard->getActiveHome(); + + $this->assertFalse( + $home->getActivePane()->hasEntry(self::TEST_DASHLET), + 'Pane::removeEntry() could not remove expected Dashlet' + ); + } + + /** + * @depends testWhetherRemoveEntryRemovesExpectedDashletEntry + */ + public function testWhetherRemoveEntriesRemovesAllDashletEntries() + { + $home = $this->getTestHome(); + $this->dashboard->manageEntry($home); + + $pane = new Pane('Test Pane'); + $home->manageEntry($pane); + + $pane->manageEntry([$this->getTestDashlet(), $this->getTestDashlet('Test Me')]); + + $this->dashboard->load(self::TEST_HOME, $pane->getName()); + + $home = $this->dashboard->getActiveHome(); + $pane = $home->getActivePane(); + + $pane->removeEntries(); + + $this->dashboard->load(); + + $home = $this->dashboard->getActiveHome(); + + $this->assertFalse( + $home->getActivePane()->hasEntries(), + 'Pane::removeEntries() could not remove all Dashlet Entries' + ); + } } diff --git a/test/php/library/Icinga/Web/Dashboard/PaneTest.php b/test/php/library/Icinga/Web/Dashboard/PaneTest.php index 0eaf3251e..6a780df62 100644 --- a/test/php/library/Icinga/Web/Dashboard/PaneTest.php +++ b/test/php/library/Icinga/Web/Dashboard/PaneTest.php @@ -204,4 +204,51 @@ class PaneTest extends BaseDashboardTestCase $default = $this->getTestHome(); $default->manageEntry($this->getTestPane(), $this->getTestPane()); } + + public function testWhetherRemoveEntryRemovesExpectedPaneEntry() + { + $home = $this->getTestHome(); + $this->dashboard->manageEntry($home); + + $home->manageEntry($this->getTestPane()); + + $this->dashboard->load(self::TEST_HOME, self::TEST_PANE); + + $home = $this->dashboard->getActiveHome(); + + $home->removeEntry(self::TEST_PANE); + $this->dashboard->load(); + + $home = $this->dashboard->getActiveHome(); + + $this->assertFalse( + $home->hasEntry(self::TEST_PANE), + 'DashboardHome::removeEntry() could not remove expected Dashboard Pane' + ); + } + + /** + * @depends testWhetherRemoveEntryRemovesExpectedPaneEntry + */ + public function testWhetherRemoveEntriesRemovesAllDashboardPanes() + { + $home = $this->getTestHome(); + $this->dashboard->manageEntry($home); + + $home->manageEntry([$this->getTestPane(), $this->getTestPane('Test Me')]); + + $this->dashboard->load(self::TEST_HOME); + + $home = $this->dashboard->getActiveHome(); + + $home->removeEntries(); + $this->dashboard->load(); + + $home = $this->dashboard->getActiveHome(); + + $this->assertFalse( + $home->hasEntries(), + 'DashboardHome::removeEntries() could not remove all Dashboard Panes' + ); + } }