public function CRMCoreRelationshipUITestCase::testRelationshipOperations in CRM Core 7
Same name and namespace in other branches
- 8.3 modules/crm_core_relationship_ui/crm_core_relationship_ui.test \CRMCoreRelationshipUITestCase::testRelationshipOperations()
- 8 modules/crm_core_relationship_ui/crm_core_relationship_ui.test \CRMCoreRelationshipUITestCase::testRelationshipOperations()
- 8.2 modules/crm_core_relationship_ui/crm_core_relationship_ui.test \CRMCoreRelationshipUITestCase::testRelationshipOperations()
File
- modules/
crm_core_relationship_ui/ crm_core_relationship_ui.test, line 20
Class
Code
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);
// Create organization and individual contacts.
$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'));
// Ensure Relationships tab on contact view page.
$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.'));
// Assert link "Add Relationship".
$this
->assertLink(t('Add a relationship'));
// Assert standard relationship types.
$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'));
// Create relationship "Employer 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'));
// Go to relationships list of the individual and ensure that
// Organization link is there.
$this
->drupalGet('crm-core/contact/1/relationships');
$this
->assertLink(CRMCoreContactUITestCase::getOrganizationContactTitle($organization_contact));
// Go to relationships list of the individual and ensure that
// Organization link is there.
$this
->drupalGet('crm-core/contact/2/relationships');
$this
->assertLink(CRMCoreContactUITestCase::getIndividualContactTitle($individual_contact));
}