You are here

class CRMCoreRelationshipUITestCase in CRM Core 8

Same name and namespace in other branches
  1. 8.3 modules/crm_core_relationship_ui/crm_core_relationship_ui.test \CRMCoreRelationshipUITestCase
  2. 8.2 modules/crm_core_relationship_ui/crm_core_relationship_ui.test \CRMCoreRelationshipUITestCase
  3. 7 modules/crm_core_relationship_ui/crm_core_relationship_ui.test \CRMCoreRelationshipUITestCase

CRMCoreRelationshipUITestCase.

@TODO: Unported.

Hierarchy

Expanded class hierarchy of CRMCoreRelationshipUITestCase

File

modules/crm_core_relationship_ui/crm_core_relationship_ui.test, line 8

View source
class CRMCoreRelationshipUITestCase extends DrupalWebTestCase {

  /**
   * {@inheritdoc}
   */
  public static function getInfo() {
    return [
      'name' => t('Relationship UI'),
      'description' => t('Test create/edit/delete relations.'),
      'group' => t('CRM Core'),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp([
      'ctools',
      'entity',
      'views',
      'image',
      'name',
      'crm_core',
      'addressfield',
      'email',
      'link',
      'cck_phone',
      'field_group',
      'name',
      'crm_core_contact',
      'crm_core_relationship',
      'crm_core_relationship_ui',
    ]);
    cache_clear_all();
  }

  /**
   * TestRelationshipOperations().
   */
  public function testRelationshipOperations() {
    $user = $this
      ->drupalCreateUser([
      '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_save_contact_button_name('individual'));
    $organization_contact = CRMCoreContactUITestCase::organizationContactValues();
    $this
      ->drupalPost('crm-core/contact/add/organization', $organization_contact, crm_core_contact_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('Employee of'));
    $this
      ->assertLink(t('Friend of'));
    $this
      ->assertLink(t('Member of'));

    // Create relationship "Employer of".
    $values = [
      /* 'source_contact' => CRMCoreContactUITestCase::getIndividualContactTitle($individual_contact) . ' [cid:1]', */
      '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));
  }

}

Members