From b9711aecc2287619bce6b663ff86df64ce60a002 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 8 Jul 2013 15:50:32 +0200 Subject: [PATCH] Host detail view: Add tests for properties Add tests for the property view helper. refs #4182 --- .../views/helpers/MonitoringProperties.php | 2 +- .../helpers/MonitoringPropertiesTest.php | 105 ++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php diff --git a/modules/monitoring/application/views/helpers/MonitoringProperties.php b/modules/monitoring/application/views/helpers/MonitoringProperties.php index 8fc621d1e..13c7a52c5 100644 --- a/modules/monitoring/application/views/helpers/MonitoringProperties.php +++ b/modules/monitoring/application/views/helpers/MonitoringProperties.php @@ -45,7 +45,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract * @var array */ private static $keys = array( - 'buildAttempt' => 'Current Attempt', + 'buildAttempt' => 'Current attempt', 'last_check' => 'Last check time', 'buildCheckType' => 'Check type', 'buildLatency' => 'Check latency / duration', diff --git a/modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php b/modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php new file mode 100644 index 000000000..0551c23bb --- /dev/null +++ b/modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php @@ -0,0 +1,105 @@ +host_current_check_attempt = '5'; + + $propertyHelper = new \Zend_View_Helper_MonitoringProperties(); + $items = $propertyHelper->monitoringProperties($host); + + $this->assertCount(10, $items); + $this->assertEquals('5/10 (HARD state)', $items['Current attempt']); + $this->assertEquals('2013-07-08 10:10:10', $items['Last update']); + } + + public function testOutput2() + { + $host = new HostStruct4Properties(); + $host->host_current_check_attempt = '5'; + $host->host_active_checks_enabled = '1'; + $host->host_passive_checks_enabled = '0'; + $host->host_is_flapping = '1'; + + $propertyHelper = new \Zend_View_Helper_MonitoringProperties(); + $items = $propertyHelper->monitoringProperties($host); + + $this->assertCount(10, $items); + + $test = array( + 'Current attempt' => "5/10 (HARD state)", + 'Last check time' => "2013-07-04 11:24:42", + 'Check type' => "ACTIVE", + 'Check latency / duration' => "0.1204 / 0.0000 seconds", + 'Next scheduled active check' => "2013-07-04 11:29:43", + 'Last state change' => "2013-07-04 13:24:43", + 'Last notification' => "N/A (notification 0)", + 'Is this host flapping?' => "YES (12.37% state change)", + 'In scheduled downtime?' => "YES", + 'Last update' => "2013-07-08 10:10:10", + ); + + $this->assertEquals($test, $items); + } +}