crm_core_relationship_ui.test in CRM Core 7
File
modules/crm_core_relationship_ui/crm_core_relationship_ui.test
View source
<?php
class CRMCoreRelationshipUITestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => t('Relationship UI'),
'description' => t('Test create/edit/delete relations.'),
'group' => t('CRM Core'),
);
}
public function setUp() {
parent::setUp(array(
'crm_core_contact_ui',
'crm_core_relationship_ui',
));
module_load_include('test', 'crm_core_contact_ui');
}
public function testRelationshipOperations() {
$user = $this
->drupalCreateUser(array(
'administer crm_core_contact entities',
'view any crm_core_contact entity',
'create relation entities of any contact relationship',
'view relation entities of any contact relationship',
'edit relation entities of any contact relationship',
));
$this
->drupalLogin($user);
$individual_contact = CRMCoreContactUITestCase::individualContactValues();
$this
->drupalPost('crm-core/contact/add/individual', $individual_contact, crm_core_contact_ui_save_contact_button_name('individual'));
$organization_contact = CRMCoreContactUITestCase::organizationContactValues();
$this
->drupalPost('crm-core/contact/add/organization', $organization_contact, crm_core_contact_ui_save_contact_button_name('organization'));
$this
->drupalGet('crm-core/contact/1');
$this
->assertLink(t('Relationships'));
$this
->drupalGet('crm-core/contact/1/relationships');
$this
->assertNoRaw('<div class="messages error">', t('No errors on Relationships page.'));
$this
->assertLink(t('Add a relationship'));
$this
->drupalGet('crm-core/contact/1/relationships/add');
$this
->assertLink(t('works for'));
$this
->assertLink(t('is friends with'));
$this
->assertLink(t('is a member of'));
$values = array(
'destination_contact' => CRMCoreContactUITestCase::getOrganizationContactTitle($organization_contact) . ' [cid:2]',
);
$this
->drupalPost('crm-core/contact/1/relationships/add/crm_employee/0', $values, t('Save Relationship'));
$this
->drupalGet('crm-core/contact/1/relationships');
$this
->assertLink(CRMCoreContactUITestCase::getOrganizationContactTitle($organization_contact));
$this
->drupalGet('crm-core/contact/2/relationships');
$this
->assertLink(CRMCoreContactUITestCase::getIndividualContactTitle($individual_contact));
}
}