Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
accognet committed Jan 31, 2025
1 parent 5d5866f commit a2a5c93
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/php-unit-tests/unitary-tests/core/InlineImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

0 comments on commit a2a5c93

Please sign in to comment.