Private GIT

Skip to content
Snippets Groups Projects
Commit 3b456737 authored by Maximilien Bersoult's avatar Maximilien Bersoult
Browse files

* Refs #5106 : Add unittest for listeners Centreon Engine Module

parent e1f50f19
No related branches found
No related tags found
No related merge requests found
Showing with 231 additions and 0 deletions
[
"cfg_modules",
"cfg_organizations",
"cfg_engine_servers",
"cfg_engine"
]
[
{
"engine_id": 1,
"log_file": "/tmp/log",
"cfg_dir": "/tmp/cfg",
"engine_server_id": 1
}
]
[
{
"id": 1,
"name": "Poller 1",
"localhost": "1",
"is_default": 1,
"last_restart": 0,
"organization_id": 1
}
]
[
{
"name": "centreon-engine",
"alias": "Centreon Engine",
"description": "Centreon Engine Module",
"version": "2.0.0",
"author": "Merethis",
"isactivated": "1",
"isinstalled": "1"
}
]
[
{
"organization_id": 1,
"name": "Organization 1",
"shortname": "organization1"
}
]
<?php
/*
* Copyright 2005-2014 MERETHIS
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation ; either version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses>.
*
* Linking this program statically or dynamically with other modules is making a
* combined work based on this program. Thus, the terms and conditions of the GNU
* General Public License cover the whole combination.
*
* As a special exception, the copyright holders of this program give MERETHIS
* permission to link this program with independent modules to produce an executable,
* regardless of the license terms of these independent modules, and to copy and
* distribute the resulting executable under terms of MERETHIS choice, provided that
* MERETHIS also meet, for each linked independent module, the terms and conditions
* of the license of that module. An independent module is a module which is not
* derived from this program. If you modify this program, you may extend this
* exception to your version of the program, but you are not obliged to do so. If you
* do not wish to do so, delete this exception statement from your version.
*
* For more information : contact@centreon.com
*/
namespace Test\CentreonEngine\Listeners\CentreonConfiguration;
use \Test\Centreon\DbTestCase;
class CopyFilesTest extends DbTestCase
{
protected $dataPath = '/modules/CentreonEngineModule/tests/data/json/';
public function testExecute()
{
$this->markTestIncomplete("Must finish the function.");
}
}
<?php
/*
* Copyright 2005-2014 MERETHIS
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation ; either version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses>.
*
* Linking this program statically or dynamically with other modules is making a
* combined work based on this program. Thus, the terms and conditions of the GNU
* General Public License cover the whole combination.
*
* As a special exception, the copyright holders of this program give MERETHIS
* permission to link this program with independent modules to produce an executable,
* regardless of the license terms of these independent modules, and to copy and
* distribute the resulting executable under terms of MERETHIS choice, provided that
* MERETHIS also meet, for each linked independent module, the terms and conditions
* of the license of that module. An independent module is a module which is not
* derived from this program. If you modify this program, you may extend this
* exception to your version of the program, but you are not obliged to do so. If you
* do not wish to do so, delete this exception statement from your version.
*
* For more information : contact@centreon.com
*/
namespace Test\CentreonEngine\Listeners\CentreonConfiguration;
use \Test\Centreon\DbTestCase;
class EngineProcessTest extends DbTestCase
{
protected $dataPath = '/modules/CentreonEngineModule/tests/data/json/';
public function testExecute()
{
$this->markTestIncomplete("Waiting manage in database the path of init script.");
}
}
<?php
/*
* Copyright 2005-2014 MERETHIS
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation ; either version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses>.
*
* Linking this program statically or dynamically with other modules is making a
* combined work based on this program. Thus, the terms and conditions of the GNU
* General Public License cover the whole combination.
*
* As a special exception, the copyright holders of this program give MERETHIS
* permission to link this program with independent modules to produce an executable,
* regardless of the license terms of these independent modules, and to copy and
* distribute the resulting executable under terms of MERETHIS choice, provided that
* MERETHIS also meet, for each linked independent module, the terms and conditions
* of the license of that module. An independent module is a module which is not
* derived from this program. If you modify this program, you may extend this
* exception to your version of the program, but you are not obliged to do so. If you
* do not wish to do so, delete this exception statement from your version.
*
* For more information : contact@centreon.com
*/
namespace Test\CentreonEngine\Listeners\CentreonConfiguration;
use \Test\Centreon\DbTestCase;
use \Centreon\Internal\Di;
use \CentreonEngine\Listeners\CentreonConfiguration\GenerateEngine;
use \CentreonConfiguration\Events\GenerateEngine as GenerateEngineEvent;
class GenerateEngineTest extends DbTestCase
{
protected $dataPath = '/modules/CentreonEngineModule/tests/data/json/';
static public function setUpBeforeClass()
{
parent::setUpBeforeClass();
$genPath = Di::getDefault()->get('config')->get('global', 'centreon_generate_tmp_dir');
if ($genPath != "" && !is_dir($genPath)) {
mkdir($genPath);
}
}
static public function tearDownAfterClass()
{
function delDir($dir) {
$fh = opendir($dir);
while ($file = readdir($fh)) {
if ($file != '.' && $file != '..') {
if (is_dir($dir . '/' . $file)) {
delDir($dir . '/' . $file);
} else {
unlink($dir . '/' . $file);
}
}
}
closedir($fh);
rmdir($dir);
}
$genPath = Di::getDefault()->get('config')->get('global', 'centreon_generate_tmp_dir');
if ($genPath != "" && is_dir($genPath)) {
delDir($genPath);
}
parent::tearDownAfterClass();
}
public function testExecute()
{
$eventParams = new GenerateEngineEvent(1);
GenerateEngine::execute($eventParams);
$genPath = Di::getDefault()->get('config')->get('global', 'centreon_generate_tmp_dir');
$this->assertTrue(file_exists($genPath . "/1/centengine.cfg"));
$this->assertTrue(file_exists($genPath . "/1/centengine-testing.cfg"));
}
}
......@@ -93,6 +93,12 @@ spl_autoload_register(function ($classname) use ($centreon_path) {
case 'controllers':
$filename .= '/controllers/'. implode('/', $fullClassPath);
break;
case 'events':
$filename .= '/events/'. implode('/', $fullClassPath);
break;
case 'listeners':
$filename .= '/listeners/'. implode('/', $fullClassPath);
break;
case 'models':
$filename .= '/models/'. implode('/', $fullClassPath);
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment