Merge pull request #5536 from totten/4.5-httpclient
[civicrm-core.git] / tests / phpunit / api / v3 / RelationshipTest.php
index fe4c6d56c8b9456564d9bf7816f2fcc9757cf418..d7d7eacd4e5f4e9ed7d2d0ba302afd6c8b655314 100644 (file)
@@ -3,7 +3,7 @@
  * +--------------------------------------------------------------------+
  * | CiviCRM version 4.6                                                |
  * +--------------------------------------------------------------------+
- * | Copyright CiviCRM LLC (c) 2004-2014                                |
+ * | Copyright CiviCRM LLC (c) 2004-2015                                |
  * +--------------------------------------------------------------------+
  * | This file is a part of CiviCRM.                                    |
  * |                                                                    |
@@ -35,7 +35,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   protected $_apiversion = 3;
   protected $_cId_a;
   /**
-   * Second individual
+   * Second individual.
    * @var integer
    */
   protected $_cId_a_2;
@@ -53,10 +53,10 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     parent::setUp();
     $this->_cId_a = $this->individualCreate();
     $this->_cId_a_2 = $this->individualCreate(array(
-        'last_name' => 'c2',
-        'email' => 'c@w.com',
-        'contact_type' => 'Individual',
-      ));
+      'last_name' => 'c2',
+      'email' => 'c@w.com',
+      'contact_type' => 'Individual',
+    ));
     $this->_cId_b = $this->organizationCreate();
     $this->_cId_b2 = $this->organizationCreate(array('organization_name' => ' Org 2'));
     $this->_entity = 'relationship';
@@ -94,14 +94,14 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   ///////////////// civicrm_relationship_create methods
 
   /**
-   * Check with empty array
+   * Check with empty array.
    */
   public function testRelationshipCreateEmpty() {
     $this->callAPIFailure('relationship', 'create', array());
   }
 
   /**
-   * Check if required fields are not passed
+   * Check if required fields are not passed.
    */
   public function testRelationshipCreateWithoutRequired() {
     $params = array(
@@ -114,7 +114,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check with incorrect required fields
+   * Check with incorrect required fields.
    */
   public function testRelationshipCreateWithIncorrectData() {
 
@@ -147,7 +147,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check relationship creation with invalid Relationship
+   * Check relationship creation with invalid Relationship.
    */
   public function testRelationshipCreatInvalidRelationship() {
     // both the contact of type Individual
@@ -174,7 +174,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check relationship already exists
+   * Check relationship already exists.
    */
   public function testRelationshipCreateAlreadyExists() {
     $params = array(
@@ -201,7 +201,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check relationship already exists
+   * Check relationship already exists.
    */
   public function testRelationshipCreateUpdateAlreadyExists() {
     $params = array(
@@ -253,7 +253,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
 
   /**
-   * Check relationship creation
+   * Check relationship creation.
    */
   public function testRelationshipCreate() {
     $params = array(
@@ -287,7 +287,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Ensure disabling works
+   * Ensure disabling works.
    */
   public function testRelationshipUpdate() {
     $result = $this->callAPISuccess('relationship', 'create', $this->_params);
@@ -307,7 +307,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check relationship creation
+   * Check relationship creation.
    */
   public function testRelationshipCreateEmptyEndDate() {
     $params = array(
@@ -345,7 +345,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check relationship creation with custom data
+   * Check relationship creation with custom data.
    */
   public function testRelationshipCreateWithCustomData() {
     $customGroup = $this->createCustomGroup();
@@ -512,7 +512,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   ///////////////// civicrm_relationship_delete methods
 
   /**
-   * Check with empty array
+   * Check with empty array.
    */
   public function testRelationshipDeleteEmpty() {
     $params = array();
@@ -520,7 +520,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check if required fields are not passed
+   * Check if required fields are not passed.
    */
   public function testRelationshipDeleteWithoutRequired() {
     $params = array(
@@ -533,7 +533,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check with incorrect required fields
+   * Check with incorrect required fields.
    */
   public function testRelationshipDeleteWithIncorrectData() {
     $params = array(
@@ -549,7 +549,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check relationship creation
+   * Check relationship creation.
    */
   public function testRelationshipDelete() {
     $params = array(
@@ -573,7 +573,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   ///////////////// civicrm_relationship_update methods
 
   /**
-   * Check with empty array
+   * Check with empty array.
    */
   public function testRelationshipUpdateEmpty() {
     $result = $this->callAPIFailure('relationship', 'create', array(),
@@ -581,11 +581,11 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check if required fields are not passed
+   * Check if required fields are not passed.
    */
 
   /**
-   * Check relationship update
+   * Check relationship update.
    */
   public function testRelationshipCreateDuplicate() {
     $relParams = array(
@@ -695,7 +695,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $getParams = array(
       'filters' => array('is_current' => 1),
     );
-    $description = "demonstrates is_current filter";
+    $description = "Demonstrates is_current filter.";
     $subfile = 'filterIsCurrent';
     //no relationship has been created
     $result = $this->callAPIAndDocument('relationship', 'get', $getParams, __FUNCTION__, __FILE__, $description, $subfile);
@@ -717,8 +717,8 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $rel2 = $this->callAPISuccess('relationship', 'create', $rel2Params);
   }
 
-  /*
-   * Test using various operators
+  /**
+   * Test using various operators.
    */
   public function testGetTypeOperators() {
     $relTypeParams = array(
@@ -765,14 +765,14 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
       'relationship_type_id' => array('IN' => array($relationType2, $relationType3)),
     );
 
-    $description = "demonstrates use of IN filter";
+    $description = "Demonstrates use of IN filter.";
     $subfile = 'INRelationshipType';
 
     $result = $this->callAPIAndDocument('relationship', 'get', $getParams, __FUNCTION__, __FILE__, $description, $subfile);
     $this->assertEquals($result['count'], 2);
     $this->AssertEquals(array($rel2['id'], $rel3['id']), array_keys($result['values']));
 
-    $description = "demonstrates use of NOT IN filter";
+    $description = "Demonstrates use of NOT IN filter.";
     $subfile = 'NotInRelationshipType';
     $getParams = array(
       'relationship_type_id' => array('NOT IN' => array($relationType2, $relationType3)),
@@ -781,7 +781,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $this->assertEquals($result['count'], 2);
     $this->AssertEquals(array($rel1['id'], $rel4['id']), array_keys($result['values']));
 
-    $description = "demonstrates use of BETWEEN filter";
+    $description = "Demonstrates use of BETWEEN filter.";
     $subfile = 'BetweenRelationshipType';
     $getParams = array(
       'relationship_type_id' => array('BETWEEN' => array($relationType2, $relationType4)),
@@ -790,7 +790,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $this->assertEquals($result['count'], 3);
     $this->AssertEquals(array($rel2['id'], $rel3['id'], $rel4['id']), array_keys($result['values']));
 
-    $description = "demonstrates use of Not BETWEEN filter";
+    $description = "Demonstrates use of Not BETWEEN filter.";
     $subfile = 'NotBetweenRelationshipType';
     $getParams = array(
       'relationship_type_id' => array('NOT BETWEEN' => array($relationType2, $relationType4)),
@@ -802,7 +802,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check with invalid relationshipType Id
+   * Check with invalid relationshipType Id.
    */
   public function testRelationshipTypeAddInvalidId() {
     $relTypeParams = array(
@@ -817,7 +817,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check with valid data with contact_b
+   * Check with valid data with contact_b.
    */
   public function testGetRelationshipWithContactB() {
     $relParams = array(
@@ -845,7 +845,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check with valid data with relationshipTypes
+   * Check with valid data with relationshipTypes.
    */
   public function testGetRelationshipWithRelTypes() {
     $relParams = array(
@@ -1000,6 +1000,8 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   }
 
   /**
+   * Test relationship get by membership type.
+   *
    * Checks that passing in 'contact_id_b' + a relationship type
    * will filter by relationship type for contact b
    *
@@ -1118,4 +1120,5 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $this->callAPISuccess($this->_entity, 'create', array('id' => $relationship['id'], 'is_active' => 0));
     $this->callAPISuccess($this->_entity, 'create', array('id' => $relationship['id'], 'is_active' => 1));
   }
+
 }