diff --git a/tests/php-unit-tests/unitary-tests/core/InlineImageTest.php b/tests/php-unit-tests/unitary-tests/core/InlineImageTest.php index 0fb188d4f1..04df96c4c8 100644 --- a/tests/php-unit-tests/unitary-tests/core/InlineImageTest.php +++ b/tests/php-unit-tests/unitary-tests/core/InlineImageTest.php @@ -69,7 +69,7 @@ public function testSetDefaultOrgIdWhenLoggedInWithContact() $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 @@ public function testSetDefaultOrgIdWhenLoggedInWithoutContact() $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'); } diff --git a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-attachments/TestAttachment.php b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-attachments/TestAttachment.php index 8485c956f0..675e0abdc8 100644 --- a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-attachments/TestAttachment.php +++ b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-attachments/TestAttachment.php @@ -69,4 +69,25 @@ public function OnRemoveAttachment(EventData $oData) $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'); + } }