From 5e14f828ba6985f22e092852f6ae05a56f06e628 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 11 Jun 2013 11:09:28 +0200 Subject: [PATCH] Evaluate, Test and Move the items und library/Icinga/Web to the source tree Fix PSR compliance. refs #4256 --- library/Icinga/Web/Form.php | 8 +++- library/Icinga/Web/Hook/Grapher.php | 5 +-- library/Icinga/Web/Hook/Toptray.php | 40 +++++++++++++++++-- library/Icinga/Web/ModuleActionController.php | 5 +-- .../Web/Paginator/Adapter/QueryAdapter.php | 3 ++ .../ScrollingStyle/SlidingWithBorder.php | 4 ++ library/Icinga/Web/Widget/AbstractWidget.php | 5 +-- library/Icinga/Web/Widget/Form.php | 5 +-- library/Icinga/Web/Widget/Tab.php | 32 ++++++++------- library/Icinga/Web/Widget/Tabs.php | 5 +-- .../Paginator/Adapter/QueryAdapterTest.php | 17 ++++++-- .../ScrollingStyle/SlidingWithBorderTest.php | 2 + 12 files changed, 92 insertions(+), 39 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index c7e538a19..5361a1868 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -1,4 +1,6 @@ align = $align; } + /** + * @return string + */ final public function getWidgetDOM() { try { - return ''; + return ''; } catch (\Exception $e) { - Logger::error("Could not create tray widget : %s",$e->getMessage()); + Logger::error("Could not create tray widget : %s", $e->getMessage()); return ''; } } + /** + * @return mixed + */ abstract protected function buildDOM(); } diff --git a/library/Icinga/Web/ModuleActionController.php b/library/Icinga/Web/ModuleActionController.php index 3c6b47e4a..76aa9fe8a 100644 --- a/library/Icinga/Web/ModuleActionController.php +++ b/library/Icinga/Web/ModuleActionController.php @@ -1,8 +1,7 @@ null, - 'title' => '', - 'url' => null, + 'name' => null, + 'title' => '', + 'url' => null, 'urlParams' => array(), - 'icon' => null, + 'icon' => null, ); /** * Health check at initialization time - * - * @throws Icinga\Exception\ProgrammingError if tab name is missing - * + * @throws \Icinga\Exception\ProgrammingError if tab name is missing * @return void */ protected function init() @@ -75,7 +72,7 @@ class Tab extends AbstractWidget */ public function setActive($active = true) { - $this->active = (bool) $active; + $this->active = (bool)$active; return $this; } @@ -100,10 +97,15 @@ class Tab extends AbstractWidget $class = $this->isActive() ? ' class="active"' : ''; $caption = $this->title; if ($this->icon !== null) { - $caption = $view->img($this->icon, array( - 'width' => 16, - 'height' => 16 - )) . ' ' . $caption; + $caption = $view->img( + $this->icon, + array( + 'width' => 16, + 'height' => 16 + ) + ) + . ' ' + . $caption; } if ($this->url !== null) { $tab = $view->qlink( diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index d3761e4ca..b3f4e9593 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -1,8 +1,7 @@ config); $query = $backend->select()->from('hostlist'); - $paginator = new QueryAdapter($query); + $adapter = new QueryAdapter($query); - $this->assertEquals(30, $paginator->count()); + $this->assertEquals(30, $adapter->count()); - $data = $paginator->getItems(0, 10); + $data = $adapter->getItems(0, 10); $this->assertCount(10, $data); - $data = $paginator->getItems(10, 20); + $data = $adapter->getItems(10, 20); $this->assertCount(10, $data); } + + public function testLimit2() + { + $backend = new Statusdat($this->config); + $query = $backend->select()->from('hostlist'); + + $adapter = new QueryAdapter($query); + $this->assertEquals(30, $adapter->count()); + } } \ No newline at end of file diff --git a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php index 781c891eb..b68438644 100755 --- a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php +++ b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php @@ -27,6 +27,8 @@ require_once '../../library/Icinga/Protocol/AbstractQuery.php'; require_once '../../library/Icinga/Protocol/Statusdat/IReader.php'; require_once '../../library/Icinga/Protocol/Statusdat/Reader.php'; require_once '../../library/Icinga/Protocol/Statusdat/Query.php'; +require_once '../../library/Icinga/Protocol/Statusdat/Parser.php'; +require_once '../../library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php'; require_once '../../library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php';