* Class CRM_Contact_BAO_ContactType_RelationshipTest
*/
class CRM_Contact_BAO_ContactType_RelationshipTest extends CiviUnitTestCase {
- /**
- * @return array
- */
- function get_info() {
- return array(
- 'name' => 'Relationship Subtype',
- 'description' => 'Test Relattionship for subtype.',
- 'group' => 'CiviCRM BAO Tests',
- );
- }
- function setUp() {
+ public function setUp() {
parent::setUp();
//create contact subtypes
$this->organization_sponsor = Contact::create($params);
}
- function tearDown() {
+ public function tearDown() {
$this->quickCleanup(array('civicrm_contact'));
$query = "
/**
* Methods create relationshipType with valid data
* success expected
- *
*/
- function testRelationshipTypeAddIndiviParent() {
+ public function testRelationshipTypeAddIndiviParent() {
//check Individual to Parent RelationshipType
$params = array(
'name_a_b' => 'indivToparent',
$this->relationshipTypeDelete($result->id);
}
- function testRelationshipTypeAddSponcorIndivi() {
+ public function testRelationshipTypeAddSponcorIndivi() {
//check Sponcor to Individual RelationshipType
$params = array(
'name_a_b' => 'SponsorToIndiv',
$this->relationshipTypeDelete($result->id);
}
- function testRelationshipTypeAddStudentSponcor() {
+ public function testRelationshipTypeAddStudentSponcor() {
//check Student to Sponcer RelationshipType
$params = array(
'name_a_b' => 'StudentToSponser',
/**
* Methods create relationshipe within same contact type with invalid Relationships
- *
*/
- function testRelationshipCreateInvalidWithinSameType() {
+ public function testRelationshipCreateInvalidWithinSameType() {
//check for Individual to Parent
$relTypeParams = array(
'name_a_b' => 'indivToparent',
'contact_sub_type_b' => $this->parent,
);
$relTypeIds = array();
- $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
- $params = array(
+ $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
+ $params = array(
'relationship_type_id' => $relType->id . '_a_b',
'contact_check' => array($this->indivi_student => 1),
);
$ids = array('contact' => $this->individual);
- list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
+ list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::createMultiple($params, $ids);
$this->assertEquals($invalid, 1, 'In line ' . __LINE__);
$this->assertEquals(empty($relationshipIds), TRUE, 'In line ' . __LINE__);
/**
* Methods create relationshipe within diff contact type with invalid Relationships
- *
*/
- function testRelCreateInvalidWithinDiffTypeSpocorIndivi() {
+ public function testRelCreateInvalidWithinDiffTypeSpocorIndivi() {
//check for Sponcer to Individual
$relTypeParams = array(
'name_a_b' => 'SponsorToIndiv',
'contact_type_b' => 'Individual',
);
$relTypeIds = array();
- $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
- $params = array(
+ $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
+ $params = array(
'relationship_type_id' => $relType->id . '_a_b',
'contact_check' => array($this->individual => 1),
);
$ids = array('contact' => $this->indivi_parent);
- list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
+ list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::createMultiple($params, $ids);
$this->assertEquals($invalid, 1, 'In line ' . __LINE__);
$this->assertEquals(empty($relationshipIds), TRUE, 'In line ' . __LINE__);
$this->relationshipTypeDelete($relType->id);
}
- function testRelCreateInvalidWithinDiffTypeStudentSponcor() {
+ public function testRelCreateInvalidWithinDiffTypeStudentSponcor() {
//check for Student to Sponcer
$relTypeParams = array(
'name_a_b' => 'StudentToSponser',
'contact_sub_type_b' => 'Sponser',
);
$relTypeIds = array();
- $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
- $params = array(
+ $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
+ $params = array(
'relationship_type_id' => $relType->id . '_a_b',
'contact_check' => array($this->individual => 1),
);
$ids = array('contact' => $this->indivi_parent);
- list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
+ list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::createMultiple($params, $ids);
$this->assertEquals($invalid, 1, 'In line ' . __LINE__);
$this->assertEquals(empty($relationshipIds), TRUE, 'In line ' . __LINE__);
/**
* Methods create relationshipe within same contact type with valid data
* success expected
- *
*/
- function testRelationshipCreateWithinSameType() {
+ public function testRelationshipCreateWithinSameType() {
//check for Individual to Parent
$relTypeParams = array(
'name_a_b' => 'indivToparent',
'contact_sub_type_b' => $this->parent,
);
$relTypeIds = array();
- $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
- $params = array(
+ $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
+ $params = array(
'relationship_type_id' => $relType->id . '_a_b',
'is_active' => 1,
'contact_check' => array($this->indivi_parent => $this->indivi_parent),
);
$ids = array('contact' => $this->individual);
- list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
+ list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::createMultiple($params, $ids);
$this->assertEquals($valid, 1, 'In line ' . __LINE__);
$this->assertEquals(empty($relationshipIds), FALSE, 'In line ' . __LINE__);
/**
* Methods create relationshipe within different contact type with valid data
* success expected
- *
*/
- function testRelCreateWithinDiffTypeSponsorIndivi() {
+ public function testRelCreateWithinDiffTypeSponsorIndivi() {
//check for Sponcer to Individual
$relTypeParams = array(
'name_a_b' => 'SponsorToIndiv',
'contact_type_b' => 'Individual',
);
$relTypeIds = array();
- $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
- $params = array(
+ $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
+ $params = array(
'relationship_type_id' => $relType->id . '_a_b',
'is_active' => 1,
'contact_check' => array($this->indivi_student => 1),
);
$ids = array('contact' => $this->organization_sponsor);
- list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
+ list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::createMultiple($params, $ids);
$this->assertEquals($valid, 1, 'In line ' . __LINE__);
$this->assertEquals(empty($relationshipIds), FALSE, 'In line ' . __LINE__);
$this->relationshipTypeDelete($relType->id);
}
- function testRelCreateWithinDiffTypeStudentSponsor() {
+ public function testRelCreateWithinDiffTypeStudentSponsor() {
//check for Student to Sponcer
$relTypeParams = array(
'name_a_b' => 'StudentToSponsor',
'contact_sub_type_b' => $this->sponsor,
);
$relTypeIds = array();
- $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
- $params = array(
+ $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
+ $params = array(
'relationship_type_id' => $relType->id . '_a_b',
'is_active' => 1,
'contact_check' => array($this->organization_sponsor => 1),
);
$ids = array('contact' => $this->indivi_student);
- list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
+ list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::createMultiple($params, $ids);
$this->assertEquals($valid, 1, 'In line ' . __LINE__);
$this->assertEquals(empty($relationshipIds), FALSE, 'In line ' . __LINE__);
$this->relationshipTypeDelete($relType->id);
}
}
-
-
-