Add tests

This commit is contained in:
Anne-Cath
2024-12-16 15:27:28 +01:00
parent 2415d3d5d3
commit add7743b6f
2 changed files with 23 additions and 2 deletions

View File

@@ -69,7 +69,7 @@ class InlineImageTest extends ItopDataTestCase
$oInlineImage->SetDefaultOrgId();
$this->assertEquals($iContactOrgId, $oInlineImage->Get('item_org_id'),'The org_id should be the one of the contact');
$oInlineImage = \MetaModel::NewObject('InlineImage',['item_class' => 'TriggerOnObjectCreation']);
$oInlineImage = \MetaModel::NewObject('InlineImage',['item_class' => 'TriggerOnObjectCreate']);
$oInlineImage->SetDefaultOrgId();
$this->assertEquals(0, $oInlineImage->Get('item_org_id'),'The org_id should be left undefined');
}
@@ -83,7 +83,7 @@ class InlineImageTest extends ItopDataTestCase
$oInlineImage->SetDefaultOrgId();
$this->assertEquals(0, $oInlineImage->Get('item_org_id'),'The org_id should be left undefined');
$oInlineImage = \MetaModel::NewObject('InlineImage',['item_class' => 'TriggerOnObjectCreation']);
$oInlineImage = \MetaModel::NewObject('InlineImage',['item_class' => 'TriggerOnObjectCreate']);
$oInlineImage->SetDefaultOrgId();
$this->assertEquals(0, $oInlineImage->Get('item_org_id'),'The org_id should be left undefined');
}

View File

@@ -69,4 +69,25 @@ class TestAttachment extends ItopDataTestCase
$oDocument = $oAttachment->Get('contents');
$this->sRemoveAttachmentName = $oDocument->GetFileName();
}
public function testSetItemOnObjectWithDefinedOrganization()
{
$iOrgId = $this->GivenObjectInDB('Organization', ['name' => 'TestOrg']);
$oUserRequest = $this->GivenObject('UserRequest', ['title' => 'TestUserRequest', 'org_id'=>$iOrgId]);
$oAttachment = new \Attachment();
$oAttachment->SetItem($oUserRequest);
$this->assertEquals($iOrgId, $oAttachment->Get('item_org_id'),'The org_id should be the one of the contact');
}
public function testSetItemOnObjectWithoutDefinedOrganization()
{
$oUserRequest = $this->GivenObject('TriggerOnObjectCreate', ['target_class' => 'UserRequest','description'=>'TestUserRequest']);
$oAttachment = new \Attachment();
$oAttachment->SetItem($oUserRequest);
$this->assertEquals(0, $oAttachment->Get('item_org_id'),'The org_id should be the one of the contact');
}
}