Skip to content

Commit

Permalink
Backend: Set name if create default backend
Browse files Browse the repository at this point in the history
fixes #7043
  • Loading branch information
mxhash committed Sep 1, 2014
1 parent 7bb5ff2 commit 160fc90
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/monitoring/library/Monitoring/Backend.php
Expand Up @@ -74,6 +74,9 @@ public static function createBackend($backendName = null)
foreach (IcingaConfig::module('monitoring', 'backends') as $name => $config) {
if (!(bool) $config->get('disabled', false) && $defaultBackend === null) {
$defaultBackend = $config;
if ($backendName === null) {
$backendName = $name;
}
}
$allBackends[$name] = $config;
}
Expand Down
31 changes: 31 additions & 0 deletions modules/monitoring/test/php/regression/Bug7043Test.php
@@ -0,0 +1,31 @@
<?php

namespace Tests\Icinga\Module\Monitoring\Regression;

use Icinga\Data\ResourceFactory;
use Icinga\Module\Monitoring\Backend;
use Icinga\Test\BaseTestCase;

class Bug7043 extends BaseTestCase
{
public function testBackendDefaultName()
{
$config = new \Zend_Config(array(
'ido' => array(
'type' => 'db',
'db' => 'mysql',
'host' => 'localhost',
'port' => '3306',
'password' => 'icinga',
'username' => 'icinga',
'dbname' => 'icinga'
)
));

ResourceFactory::setConfig($config);

$defaultBackend = Backend::createBackend();

$this->assertNotNull($defaultBackend->getName(), 'Default backend has a name property set');
}
}

0 comments on commit 160fc90

Please sign in to comment.