Merge branch 'bugfix/service-set-tests'
This commit is contained in:
commit
02c3625a76
|
@ -22,7 +22,7 @@ CentOS 7/MySQL:
|
|||
after_script:
|
||||
- mysql -u root -e "DROP DATABASE $DIRECTOR_TESTDB"
|
||||
script:
|
||||
- phpunit
|
||||
- phpunit --verbose
|
||||
|
||||
CentOS 7/PostgreSQL:
|
||||
stage: Unit-Tests with DB
|
||||
|
@ -40,7 +40,7 @@ CentOS 7/PostgreSQL:
|
|||
- psql postgres -c "DROP DATABASE $DIRECTOR_TESTDB"
|
||||
- psql postgres -c "DROP USER $DIRECTOR_TESTDB_USER"
|
||||
script:
|
||||
- phpunit
|
||||
- phpunit --verbose
|
||||
|
||||
#CentOS 6/MySQL:
|
||||
# stage: Unit-Tests with DB
|
||||
|
@ -70,7 +70,7 @@ Jessie/MySQL:
|
|||
after_script:
|
||||
- mysql -u root -e "DROP DATABASE $DIRECTOR_TESTDB"
|
||||
script:
|
||||
- phpunit
|
||||
- phpunit --verbose
|
||||
|
||||
Jessie/PostgreSQL:
|
||||
stage: Unit-Tests with DB
|
||||
|
@ -88,7 +88,7 @@ Jessie/PostgreSQL:
|
|||
- psql postgres -c "DROP DATABASE $DIRECTOR_TESTDB"
|
||||
- psql postgres -c "DROP USER $DIRECTOR_TESTDB_USER"
|
||||
script:
|
||||
- phpunit
|
||||
- phpunit --verbose
|
||||
|
||||
Xenial/MySQL:
|
||||
stage: Unit-Tests with DB
|
||||
|
@ -103,7 +103,7 @@ Xenial/MySQL:
|
|||
after_script:
|
||||
- mysql -u root -e "DROP DATABASE $DIRECTOR_TESTDB"
|
||||
script:
|
||||
- phpunit
|
||||
- phpunit --verbose
|
||||
|
||||
Xenial/PostgreSQL:
|
||||
stage: Unit-Tests with DB
|
||||
|
@ -121,5 +121,5 @@ Xenial/PostgreSQL:
|
|||
- psql postgres -c "DROP DATABASE $DIRECTOR_TESTDB"
|
||||
- psql postgres -c "DROP USER $DIRECTOR_TESTDB_USER"
|
||||
script:
|
||||
- phpunit
|
||||
- phpunit --verbose
|
||||
|
||||
|
|
|
@ -2633,10 +2633,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
|
||||
public function listImportNames()
|
||||
{
|
||||
if ($this->hasBeenModified()
|
||||
&& $this->imports !== null
|
||||
&& $this->imports()->hasBeenModified()
|
||||
) {
|
||||
if ($this->gotImports()) {
|
||||
return $this->imports()->listImportNames();
|
||||
} else {
|
||||
return $this->templateTree()->listParentNamesFor($this);
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Objects;
|
|||
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Module\Director\Exception\DuplicateKeyException;
|
||||
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
||||
|
||||
|
@ -249,16 +250,37 @@ class IcingaServiceSet extends IcingaObject
|
|||
}
|
||||
}
|
||||
|
||||
public function createWhere()
|
||||
{
|
||||
$where = parent::createWhere();
|
||||
if (! $this->hasBeenLoadedFromDb()) {
|
||||
if (null === $this->get('host_id') && null === $this->get('id')) {
|
||||
$where .= " AND object_type = 'template'";
|
||||
}
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
protected function beforeStore()
|
||||
{
|
||||
parent::beforeStore();
|
||||
|
||||
$name = $this->getObjectName();
|
||||
|
||||
if ($this->isObject() && $this->get('host_id') === null) {
|
||||
throw new ProgrammingError(
|
||||
'A Service Set cannot be an object with no related host'
|
||||
);
|
||||
}
|
||||
// checking if template object_name is unique
|
||||
// TODO: Move to IcingaObject
|
||||
if (! $this->hasBeenLoadedFromDb() && $this->isTemplate() && static::exists($name, $this->connection)) {
|
||||
throw new DuplicateKeyException('%s template "%s" already existing in database!', $this->getType(), $name);
|
||||
throw new DuplicateKeyException(
|
||||
'%s template "%s" already existing in database!',
|
||||
$this->getType(),
|
||||
$name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,9 +64,10 @@ class IcingaServiceSetTest extends IcingaObjectTestCase
|
|||
|
||||
public function testDeletingHostWithSet()
|
||||
{
|
||||
$this->markTestIncomplete('Host deletion fails / does not cleanup sets!');
|
||||
|
||||
$this->testAddingSetToHost();
|
||||
$this->createObject('for_set', 'icinga_host', array(
|
||||
'object_type' => 'object',
|
||||
'address' => '1.2.3.4',
|
||||
), false)->store();
|
||||
|
||||
$host = $this->loadObject('for_set', 'icinga_host');
|
||||
$host->delete();
|
||||
|
@ -106,13 +107,10 @@ class IcingaServiceSetTest extends IcingaObjectTestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icinga\Exception\ProgrammingError
|
||||
* @expectedException \Icinga\Exception\IcingaException
|
||||
*/
|
||||
public function testCreatingSetWithoutType()
|
||||
{
|
||||
// TODO: fix error
|
||||
$this->markTestIncomplete('Throws a database error, not a proper exception!');
|
||||
|
||||
$set = IcingaServiceSet::create(array(
|
||||
'object_name' => '___TEST__set_BAD',
|
||||
));
|
||||
|
@ -124,16 +122,12 @@ class IcingaServiceSetTest extends IcingaObjectTestCase
|
|||
*/
|
||||
public function testCreatingHostSetWithoutHost()
|
||||
{
|
||||
$this->markTestIncomplete('Throws no error currently, but will create the object');
|
||||
|
||||
/* TODO: fix this, it will create an object currently
|
||||
$set = IcingaServiceSet::create(array(
|
||||
'object_name' => '___TEST__set_BAD2',
|
||||
'object_type' => 'object',
|
||||
));
|
||||
|
||||
$set->store($this->getDb());
|
||||
*/
|
||||
}
|
||||
|
||||
public function testDeletingSet()
|
||||
|
|
Loading…
Reference in New Issue