N°6271 - Fix drop-down list not refreshed when adding an external key with a friendlyname built on an external key

This commit is contained in:
Eric Espie
2023-06-26 18:00:04 +02:00
parent a206af1813
commit db6e4137b1
5 changed files with 61 additions and 18 deletions

View File

@@ -140,7 +140,7 @@ class DBObjectTest extends ItopDataTestCase
* @covers DBObject::Get
* @covers DBObject::Set
*/
public function testAttributeRefresh_FriendlyName()
public function testAttributeRefresh_FriendlyNameWithoutCascade()
{
$oObject = \MetaModel::NewObject('Person', array('name' => 'Foo', 'first_name' => 'John', 'org_id' => 3, 'location_id' => 2));
@@ -149,6 +149,21 @@ class DBObjectTest extends ItopDataTestCase
static::assertEquals('John Who', $oObject->Get('friendlyname'));
}
/**
* @covers DBObject::NewObject
* @covers DBObject::Get
* @covers DBObject::Set
*/
public function testAttributeRefresh_FriendlyNameWithCascade()
{
$oServer = \MetaModel::NewObject('Server', ['name' => 'ServerTest', 'org_id' => 3]);
$oServer->DBInsert();
$oDBServer = \MetaModel::NewObject('DBServer', ['name' => 'DBServerTest', 'org_id' => 3, 'system_id' => $oServer]);
static::assertEquals('ServerTest', $oDBServer->Get('system_name'));
static::assertEquals('DBServerTest ServerTest', $oDBServer->Get('friendlyname'));
}
/**
* @covers MetaModel::GetObject
* @covers DBObject::Get
@@ -174,8 +189,7 @@ class DBObjectTest extends ItopDataTestCase
public function testPartialAttributeEvaluation()
{
$oObject = \MetaModel::NewObject('Person', array('name' => 'Foo', 'org_id' => 3, 'location_id' => 2));
static::assertEquals('', $oObject->Get('friendlyname'));
static::assertEquals(' Foo', $oObject->Get('friendlyname'));
}
/**
@@ -186,7 +200,7 @@ class DBObjectTest extends ItopDataTestCase
{
$oObject = \MetaModel::NewObject('Person', array('org_id' => 3, 'location_id' => 2));
static::assertEquals('', $oObject->Get('friendlyname'));
static::assertEquals(' ', $oObject->Get('friendlyname'));
}
/**
@@ -198,7 +212,7 @@ class DBObjectTest extends ItopDataTestCase
$oUserProfile = new \URP_UserProfile();
$oUserProfile->Set('profileid', 2);
static::assertEquals('', $oUserProfile->Get('friendlyname'));
static::assertEquals('Link between and Portal user', $oUserProfile->Get('friendlyname'));
}
/**
@@ -206,7 +220,7 @@ class DBObjectTest extends ItopDataTestCase
* @covers DBObject::Get
* @covers DBObject::Set
*/
public function testAttributeRefresh_ObsolescenceFlag()
public function testAttributeRefresh_ObsolescenceFlagWithoutCascade()
{
$oObject = \MetaModel::NewObject('Person', array('name' => 'Foo', 'first_name' => 'John', 'org_id' => 3, 'location_id' => 2));
@@ -215,6 +229,24 @@ class DBObjectTest extends ItopDataTestCase
static::assertEquals(true, (bool)$oObject->Get('obsolescence_flag'));
}
/**
* @covers DBObject::NewObject
* @covers DBObject::Get
* @covers DBObject::Set
*/
public function testAttributeRefresh_ObsolescenceFlagWithCascade()
{
$this->markTestSkipped('Postponed');
// Necessary ext. key for $oDBServer
$oServer = \MetaModel::NewObject('Server', ['name' => 'ServerTest', 'org_id' => 3]);
$oServer->DBInsert();
$oDBServer = \MetaModel::NewObject('DBServer', ['name' => 'DBServerTest', 'org_id' => 3, 'system_id' => $oServer, 'status' => 'inactive']);
$oDBServer->DBInsert();
$oDBSchema = \MetaModel::NewObject('DatabaseSchema', ['name' => 'DBSchemaTest', 'org_id' => 3, 'dbserver_id' => $oDBServer]);
static::assertEquals(true, $oDBSchema->Get('obsolescence_flag'));
}
/**
* @covers DBObject::NewObject
* @covers DBObject::Get