[icinga-checkins] icinga.org: icingaweb2/feature/add-to-dashboard-4537: Dashbosrd: Fix tests

git at icinga.org git at icinga.org
Tue Nov 18 17:26:46 CET 2014


Module: icingaweb2
Branch: feature/add-to-dashboard-4537
Commit: 8c3dbb2b45b758f214752819a02c07ea785f6f71
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=8c3dbb2b45b758f214752819a02c07ea785f6f71

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Nov 18 17:26:28 2014 +0100

Dashbosrd: Fix tests

refs #4537

---

 .../library/Icinga/Web/Widget/DashboardTest.php    |  107 +-------------------
 1 file changed, 5 insertions(+), 102 deletions(-)

diff --git a/test/php/library/Icinga/Web/Widget/DashboardTest.php b/test/php/library/Icinga/Web/Widget/DashboardTest.php
index be11c42..2172748 100644
--- a/test/php/library/Icinga/Web/Widget/DashboardTest.php
+++ b/test/php/library/Icinga/Web/Widget/DashboardTest.php
@@ -131,7 +131,8 @@ class DashboardTest extends BaseTestCase
      */
     public function testLoadPaneItemsProvidedByEnabledModules()
     {
-        $dashboard = Dashboard::load();
+        $dashboard = new Dashboard();
+        $dashboard->load();
 
         $this->assertCount(
             1,
@@ -270,36 +271,10 @@ class DashboardTest extends BaseTestCase
         $component2 = new Component('test2', 'test2', $pane);
         $pane->addComponent($component2);
 
-        $dashboard->removeComponent('test1', 'test');
-
-        $result = $dashboard->getPane('test1')->hasComponent('test');
-
-        $this->assertFalse(
-            $result,
-            'Dashboard::removeComponent() could not remove component from the pane'
-        );
-    }
-
-    /**
-     * @depends testWhetherGetPaneReturnsAPaneByName
-     */
-    public function testWhetherRemoveComponentRemovesComponentByConcatenation()
-    {
-        $dashboard = new Dashboard();
-        $dashboard->createPane('test1');
-        $pane = $dashboard->getPane('test1');
-
-        $component = new Component('test', 'test', $pane);
-        $pane->addComponent($component);
-
-        $component2 = new Component('test2', 'test2', $pane);
-        $pane->addComponent($component2);
-
-        $dashboard->removeComponent('test1.test', null);
-
+        $dashboard->getPane('test1')->removeComponent('test');
         $result = $dashboard->getPane('test1')->hasComponent('test');
 
-        $this->assertFalse(
+        $this->assertTrue(
             $result,
             'Dashboard::removeComponent() could not remove component from the pane'
         );
@@ -308,36 +283,6 @@ class DashboardTest extends BaseTestCase
     /**
      * @depends testWhetherGetPaneReturnsAPaneByName
      */
-    public function testWhetherToArrayReturnsDashboardStructureAsArray()
-    {
-        $dashboard = new Dashboard();
-        $dashboard->createPane('test1');
-        $pane = $dashboard->getPane('test1');
-
-        $component = new Component('test', 'test', $pane);
-        $pane->addComponent($component);
-
-        $result = $dashboard->toArray();
-
-        $expected = array(
-            'test1' => array(
-                'title' => 'test1'
-            ),
-            'test1.test' => array(
-                'url' => 'test'
-            )
-        );
-
-        $this->assertEquals(
-            $expected,
-            $result,
-            'Dashboard::toArray() could not return valid expectation'
-        );
-    }
-
-    /**
-     * @depends testWhetherGetPaneReturnsAPaneByName
-     */
     public function testWhetherSetComponentUrlUpdatesTheComponentUrl()
     {
         $dashboard = new Dashboard();
@@ -346,27 +291,7 @@ class DashboardTest extends BaseTestCase
         $component = new Component('test', 'test', $pane);
         $pane->addComponent($component);
 
-        $dashboard->setComponentUrl('test1', 'test', 'new');
-
-        $this->assertEquals(
-            'new',
-            $component->getUrl()->getPath(),
-            'Dashboard::setComponentUrl() could not return valid expectation'
-        );
-    }
-
-    /**
-     * @depends testWhetherGetPaneReturnsAPaneByName
-     */
-    public function testWhetherSetComponentUrlUpdatesTheComponentUrlConcatenation()
-    {
-        $dashboard = new Dashboard();
-        $dashboard->createPane('test1');
-        $pane = $dashboard->getPane('test1');
-        $component = new Component('test', 'test', $pane);
-        $pane->addComponent($component);
-
-        $dashboard->setComponentUrl('test1.test', null, 'new');
+        $dashboard->getPane('test1')->getComponent('test')->setUrl('new');
 
         $this->assertEquals(
             'new',
@@ -376,28 +301,6 @@ class DashboardTest extends BaseTestCase
     }
 
     /**
-     * @depends testWhetherGetPaneReturnsAPaneByName
-     */
-    public function testWhetherSetComponentUrlUpdatesTheComponentUrlNotExistentPane()
-    {
-        $dashboard = new Dashboard();
-        $dashboard->createPane('test1');
-        $pane = $dashboard->getPane('test1');
-        $component = new Component('test', 'test', $pane);
-        $pane->addComponent($component);
-
-        $dashboard->setComponentUrl('test3.test', null, 'new');
-
-        $result = $dashboard->getPane('test3')->getComponent('test');
-
-        $this->assertEquals(
-            'new',
-            $result->getUrl()->getPath(),
-            'Dashboard::setComponentUrl() could not return valid expectation'
-        );
-    }
-
-    /**
      * @expectedException \Icinga\Exception\ConfigurationError
      */
     public function testWhetherDetermineActivePaneThrowsAnExceptionIfCouldNotDetermine()



More information about the icinga-checkins mailing list