* +--------------------------------------------------------------------+
* | CiviCRM version 5 |
* +--------------------------------------------------------------------+
- * | Copyright CiviCRM LLC (c) 2004-2018 |
+ * | Copyright CiviCRM LLC (c) 2004-2019 |
* +--------------------------------------------------------------------+
* | This file is a part of CiviCRM. |
* | |
$this->callAPIFailure('relationship', 'create', array());
}
+ /**
+ * Test Current Employer is correctly set.
+ */
+ public function testCurrentEmployerRelationship() {
+ $employerRelationshipID = $this->callAPISuccessGetValue('RelationshipType', array(
+ 'return' => "id",
+ 'name_b_a' => "Employer Of",
+ ));
+ $employerRelationship = $this->callAPISuccess('Relationship', 'create', array(
+ 'contact_id_a' => $this->_cId_a,
+ 'contact_id_b' => $this->_cId_b,
+ 'relationship_type_id' => $employerRelationshipID,
+ ));
+ $params = array($this->_cId_a => $this->_cId_b);
+ CRM_Contact_BAO_Contact_Utils::setCurrentEmployer($params);
+
+ //Check if current employer is correctly set.
+ $employer = $this->callAPISuccessGetValue('Contact', array(
+ 'return' => "current_employer",
+ 'id' => $this->_cId_a,
+ ));
+ $organisation = $this->callAPISuccessGetValue('Contact', array(
+ 'return' => "sort_name",
+ 'id' => $this->_cId_b,
+ ));
+ $this->assertEquals($employer, $organisation);
+
+ //Update relationship type
+ $update = $this->callAPISuccess('Relationship', 'create', array(
+ 'id' => $employerRelationship['id'],
+ 'relationship_type_id' => $this->_relTypeID,
+ ));
+ $employeeContact = $this->callAPISuccessGetSingle('Contact', array(
+ 'return' => array("current_employer"),
+ 'id' => $this->_cId_a,
+ ));
+ //current employer should be removed.
+ $this->assertEmpty($employeeContact['current_employer']);
+ }
+
/**
* Check if required fields are not passed.
*/