INFRA-132 add full stop after comments
[civicrm-core.git] / tests / phpunit / api / v3 / ActivityTest.php
index 5bdc9ecc7e3be72d133f22fb1920ea5b90e16d60..b6faedbc7b984293aaeb6f076e965c1eabcc4ec8 100644 (file)
@@ -1,15 +1,16 @@
 <?php
 /**
+ * @file
  *  File for the TestActivity class
  *
  *  (PHP 5)
  *
- *   @author Walt Haas <walt@dharmatech.org> (801) 534-1262
- *   @copyright Copyright CiviCRM LLC (C) 2009
- *   @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html
+ * @author Walt Haas <walt@dharmatech.org> (801) 534-1262
+ * @copyright Copyright CiviCRM LLC (C) 2009
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html
  *              GNU Affero General Public License version 3
- *   @version   $Id: ActivityTest.php 31254 2010-12-15 10:09:29Z eileen $
- *   @package   CiviCRM
+ * @version   $Id: ActivityTest.php 31254 2010-12-15 10:09:29Z eileen $
+ * @package   CiviCRM
  *
  *   This file is part of CiviCRM
  *
@@ -35,12 +36,11 @@ require_once 'CiviTest/CiviUnitTestCase.php';
 
 
 /**
- *  Test APIv3 civicrm_activity_* functions
+ * Test APIv3 civicrm_activity_* functions
  *
- *  @package CiviCRM_APIv3
- *  @subpackage API_Activity
+ * @package CiviCRM_APIv3
+ * @subpackage API_Activity
  */
-
 class api_v3_ActivityTest extends CiviUnitTestCase {
   protected $_params;
   protected $_params2;
@@ -50,13 +50,13 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   protected $_contactID;
 
   /**
-   *  Test setup for every test
+   * Test setup for every test.
    *
-   *  Connect to the database, truncate the tables that will be used
-   *  and redirect stdin to a temporary file
+   * Connect to the database, truncate the tables that will be used
+   * and redirect stdin to a temporary file
    */
   public function setUp() {
-    //  Connect to the database
+    // Connect to the database
     parent::setUp();
 
     $this->_contactID = $this->individualCreate();
@@ -65,7 +65,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
       'option_group_id' => 2,
       'name' => 'Test activity type',
       'label' => 'Test activity type',
-      'sequential' => 1
+      'sequential' => 1,
     ));
     $this->test_activity_type_value = $activityTypes['values'][0]['value'];
     $this->test_activity_type_id = $activityTypes['id'];
@@ -77,7 +77,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
       'status_id' => 2,
       'priority_id' => 1,
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
     );
     $this->_params2 = array(
@@ -96,11 +96,10 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
 
   /**
    * Tears down the fixture, for example, closes a network connection.
-   * This method is called after a test is executed.
    *
-   * @access protected
+   * This method is called after a test is executed.
    */
-  function tearDown() {
+  public function tearDown() {
     $tablesToTruncate = array(
       'civicrm_contact',
       'civicrm_activity',
@@ -111,16 +110,16 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   * check with empty array
+   * Check fails with empty array.
    */
-  function testActivityCreateEmpty() {
-    $result = $this->callAPIFailure('activity', 'create', array());
+  public function testActivityCreateEmpty() {
+    $this->callAPIFailure('activity', 'create', array());
   }
 
   /**
-   * check if required fields are not passed
+   * Check if required fields are not passed.
    */
-  function testActivityCreateWithoutRequired() {
+  public function testActivityCreateWithoutRequired() {
     $params = array(
       'subject' => 'this case should fail',
       'scheduled_date_time' => date('Ymd'),
@@ -129,16 +128,16 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activity_create() with mismatched activity_type_id
-   *  and activity_name
+   * Test civicrm_activity_create() with mismatched activity_type_id
+   * and activity_name.
    */
-  function testActivityCreateMismatchNameType() {
+  public function testActivityCreateMismatchNameType() {
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Test activity',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_name' => 'Fubar activity type',
@@ -150,38 +149,38 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activity_id() with missing source_contact_id is put with the current user.
+   * Test civicrm_activity_id() with missing source_contact_id is put with the current user.
    */
-  function testActivityCreateWithMissingContactId() {
+  public function testActivityCreateWithMissingContactId() {
     $params = array(
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_name' => 'Test activity type',
     );
 
-    $result = $this->callAPISuccess('activity', 'create', $params);
+    $this->callAPISuccess('activity', 'create', $params);
   }
 
   /**
-   *  Test civicrm_activity_id() with non-numeric source_contact_id
+   * Test civicrm_activity_id() with non-numeric source_contact_id.
    */
-  function testActivityCreateWithNonNumericContactId() {
+  public function testActivityCreateWithNonNumericContactId() {
     $params = array(
       'source_contact_id' => 'fubar',
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_name' => 'Test activity type',
     );
 
-    $result = $this->callAPIFailure('activity', 'create', $params);
+    $this->callAPIFailure('activity', 'create', $params);
   }
 
   /**
@@ -189,13 +188,13 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
    * oddly enough this test was failing because the creation of the invalid type
    * got added to the set up routine. Probably a mis-fix on a test
    */
-  function testActivityCreateWithNonNumericActivityTypeId() {
+  public function testActivityCreateWithNonNumericActivityTypeId() {
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_type_id' => 'Invalid Test activity type',
@@ -205,15 +204,15 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   * check with incorrect required fields
+   * Check with incorrect required fields.
    */
-  function testActivityCreateWithUnknownActivityTypeId() {
+  public function testActivityCreateWithUnknownActivityTypeId() {
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_type_id' => 699,
@@ -222,13 +221,13 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     $result = $this->callAPIFailure('activity', 'create', $params);
   }
 
-  function testActivityCreateWithInvalidPriority() {
+  public function testActivityCreateWithInvalidPriority() {
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'priority_id' => 44,
@@ -241,14 +240,16 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
 
-
-  function testActivityCreateWithValidStringPriority() {
+  /**
+   * Test create succeeds with valid string for priority.
+   */
+  public function testActivityCreateWithValidStringPriority() {
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'priority_id' => 'Urgent',
@@ -259,53 +260,54 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     $this->assertEquals(1, $result['values'][$result['id']]['priority_id']);
   }
 
-  function testActivityCreateWithInValidStringPriority() {
+  /**
+   * Test create fails with invalid priority string.
+   */
+  public function testActivityCreateWithInValidStringPriority() {
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'priority_id' => 'ergUrgent',
       'activity_type_id' => 1,
     );
 
-    $result = $this->callAPIFailure('activity', 'create', $params,
+    $this->callAPIFailure('activity', 'create', $params,
       "'ergUrgent' is not a valid option for field priority_id");
   }
 
   /**
-   *  Test civicrm_activity_create() with valid parameters
+   * Test civicrm_activity_create() with valid parameters.
    */
-  function testActivityCreate() {
+  public function testActivityCreate() {
 
-    $result = $this->callAPISuccess('activity', 'create', $this->_params);
+    $this->callAPISuccess('activity', 'create', $this->_params);
     $result = $this->callAPISuccess('activity', 'get', $this->_params);
-    $this->assertEquals($result['values'][$result['id']]['duration'], 120, 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['subject'], 'test activity type id', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['activity_date_time'], '2011-06-02 14:36:13', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['location'], 'Pensulvania', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['details'], 'a test activity', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['status_id'], 2, 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['id'], $result['id'], 'in line ' . __LINE__);
+    $this->assertEquals($result['values'][$result['id']]['duration'], 120);
+    $this->assertEquals($result['values'][$result['id']]['subject'], 'test activity type id');
+    $this->assertEquals($result['values'][$result['id']]['activity_date_time'], '2011-06-02 14:36:13');
+    $this->assertEquals($result['values'][$result['id']]['location'], 'Pennsylvania');
+    $this->assertEquals($result['values'][$result['id']]['details'], 'a test activity');
+    $this->assertEquals($result['values'][$result['id']]['status_id'], 2);
+    $this->assertEquals($result['values'][$result['id']]['id'], $result['id']);
   }
 
   /**
-   *  Test civicrm_activity_create() with valid parameters - use type_id
+   * Test civicrm_activity_create() with valid parameters - use type_id.
    */
-  function testActivityCreateCampaignTypeID() {
+  public function testActivityCreateCampaignTypeID() {
     $this->enableCiviCampaign();
 
-    $defaults = array();
-
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => '20110316',
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_type_id' => 29,
@@ -313,28 +315,29 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     );
 
     $result = $this->callAPISuccess('activity', 'create', $params);
-    //todo test target & assignee are set
 
-    //$this->assertEquals($result['values'][$result['id']]['source_contact_id'], $this->_contactID, 'in line ' . __LINE__);
     $result = $this->callAPISuccess('activity', 'get', array('id' => $result['id']));
-    $this->assertEquals($result['values'][$result['id']]['duration'], 120, 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['subject'], 'Make-it-Happen Meeting', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['activity_date_time'], '2011-03-16 00:00:00', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['location'], 'Pensulvania', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['details'], 'a test activity', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['status_id'], 1, 'in line ' . __LINE__);
+    $this->assertEquals($result['values'][$result['id']]['duration'], 120);
+    $this->assertEquals($result['values'][$result['id']]['subject'], 'Make-it-Happen Meeting');
+    $this->assertEquals($result['values'][$result['id']]['activity_date_time'], '2011-03-16 00:00:00');
+    $this->assertEquals($result['values'][$result['id']]['location'], 'Pennsylvania');
+    $this->assertEquals($result['values'][$result['id']]['details'], 'a test activity');
+    $this->assertEquals($result['values'][$result['id']]['status_id'], 1);
   }
 
-  function testActivityReturnTargetAssignee() {
+  /**
+   * Test get returns target and assignee contacts.
+   */
+  public function testActivityReturnTargetAssignee() {
 
     $description = "Example demonstrates setting & retrieving the target & source";
-    $subfile     = "GetTargetandAssignee";
-    $params      = array(
+    $subfile = "GetTargetandAssignee";
+    $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => '20110316',
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_type_id' => 1,
@@ -344,16 +347,21 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     );
 
     $result = $this->callAPIAndDocument('activity', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
-    $result = $this->callAPISuccess('activity', 'get', array('id' => $result['id'], 'version' => $this->_apiversion, 'return.assignee_contact_id' => 1, 'return.target_contact_id' => 1));
+    $result = $this->callAPISuccess('activity', 'get', array(
+      'id' => $result['id'],
+      'version' => $this->_apiversion,
+      'return.assignee_contact_id' => 1,
+      'return.target_contact_id' => 1,
+    ));
 
-    $this->assertEquals($this->_contactID, $result['values'][$result['id']]['assignee_contact_id'][0], 'in line ' . __LINE__);
-    $this->assertEquals($this->_contactID, $result['values'][$result['id']]['target_contact_id'][0], 'in line ' . __LINE__);
+    $this->assertEquals($this->_contactID, $result['values'][$result['id']]['assignee_contact_id'][0]);
+    $this->assertEquals($this->_contactID, $result['values'][$result['id']]['target_contact_id'][0]);
   }
 
-  function testActivityCreateExample() {
-    /**
-     *  Test civicrm_activity_create() using example code
-     */
+  /**
+   * Test civicrm_activity_create() using example code.
+   */
+  public function testActivityCreateExample() {
     require_once 'api/v3/examples/Activity/Create.php';
     $result = activity_create_example();
     $expectedResult = activity_create_expectedresult();
@@ -361,15 +369,17 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activity_create() with valid parameters
-   *  and some custom data
+   * Test civicrm_activity_create() with valid parameters and custom data.
    */
-  function testActivityCreateCustom() {
+  public function testActivityCreateCustom() {
     $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
     $params = $this->_params;
     $params['custom_' . $ids['custom_field_id']] = "custom string";
     $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
-    $result = $this->callAPISuccess($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'version' => 3, 'id' => $result['id']));
+    $result = $this->callAPISuccess($this->_entity, 'get', array(
+      'return.custom_' . $ids['custom_field_id'] => 1,
+      'id' => $result['id'],
+    ));
     $this->assertEquals("custom string", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
 
     $this->customFieldDelete($ids['custom_field_id']);
@@ -377,16 +387,15 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activity_create() with valid parameters
-   *  and some custom data
+   * Test civicrm_activity_create() with valid parameters and custom data.
    */
-  function testActivityCreateCustomContactRefField() {
+  public function testActivityCreateCustomContactRefField() {
 
     $this->callAPISuccess('contact', 'create', array('id' => $this->_contactID, 'sort_name' => 'Contact, Test'));
-    $subfile     = 'ContactRefCustomField';
+    $subfile = 'ContactRefCustomField';
     $description = "demonstrates create with Contact Reference Custom Field";
-    $ids         = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
-    $params      = array(
+    $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
+    $params = array(
       'custom_group_id' => $ids['custom_group_id'],
       'name' => 'Worker_Lookup',
       'label' => 'Worker Lookup',
@@ -402,9 +411,12 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     $params['custom_' . $customField['id']] = "$this->_contactID";
 
     $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, $subfile, 'Create');
-    $result = $this->callAPIAndDocument($this->_entity, 'get', array('return.custom_' . $customField['id'] => 1, 'id' => $result['id']), __FUNCTION__, __FILE__, 'Get with Contact Ref Custom Field', 'ContactRefCustomFieldGet', 'get');
+    $result = $this->callAPIAndDocument($this->_entity, 'get', array(
+      'return.custom_' . $customField['id'] => 1,
+      'id' => $result['id'],
+    ), __FUNCTION__, __FILE__, 'Get with Contact Ref Custom Field', 'ContactRefCustomFieldGet', 'get');
 
-    $this->assertEquals('Anderson, Anthony', $result['values'][$result['id']]['custom_' . $customField['id']], ' in line ' . __LINE__);
+    $this->assertEquals('Anderson, Anthony', $result['values'][$result['id']]['custom_' . $customField['id']]);
     $this->assertEquals($this->_contactID, $result['values'][$result['id']]['custom_' . $customField['id'] . "_id"], ' in line ' . __LINE__);
     $this->assertEquals('Anderson, Anthony', $result['values'][$result['id']]['custom_' . $customField['id'] . '_1'], ' in line ' . __LINE__);
     $this->assertEquals($this->_contactID, $result['values'][$result['id']]['custom_' . $customField['id'] . "_1_id"], ' in line ' . __LINE__);
@@ -413,35 +425,35 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activity_create() with an invalid text status_id
+   * Test civicrm_activity_create() with an invalid text status_id.
    */
-  function testActivityCreateBadTextStatus() {
+  public function testActivityCreateBadTextStatus() {
 
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Discussion on Apis for v3',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 'Invalid',
       'activity_name' => 'Test activity type',
     );
 
-    $result = $this->callAPIFailure('activity', 'create', $params);
+    $this->callAPIFailure('activity', 'create', $params);
   }
 
   /**
-   *  Test civicrm_activity_create() with an invalid text status_id
+   * Test civicrm_activity_create() with an invalid text status_id.
    */
-  function testActivityCreateSupportActivityStatus() {
+  public function testActivityCreateSupportActivityStatus() {
 
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Discussion on Apis for v3',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'activity_status_id' => 'Invalid',
       'activity_name' => 'Test activity type',
@@ -453,57 +465,56 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
 
 
   /**
-   *  Test civicrm_activity_create() with valid parameters,
-   *  using a text status_id
+   * Test civicrm_activity_create() with using a text status_id.
    */
-  function testActivityCreateTextStatus() {
-
+  public function testActivityCreateTextStatus() {
 
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => date('Ymd'),
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 'Scheduled',
       'activity_name' => 'Test activity type',
     );
 
     $result = $this->callAPISuccess('activity', 'create', $params);
-    $this->assertEquals($result['values'][$result['id']]['duration'], 120, 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['subject'], 'Make-it-Happen Meeting', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['activity_date_time'], date('Ymd') . '000000', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['location'], 'Pensulvania', 'in line ' . __LINE__);
-    $this->assertEquals($result['values'][$result['id']]['details'], 'a test activity', 'in line ' . __LINE__);
+    $this->assertEquals($result['values'][$result['id']]['duration'], 120);
+    $this->assertEquals($result['values'][$result['id']]['subject'], 'Make-it-Happen Meeting');
+    $this->assertEquals($result['values'][$result['id']]['activity_date_time'], date('Ymd') . '000000');
+    $this->assertEquals($result['values'][$result['id']]['location'], 'Pennsylvania');
+    $this->assertEquals($result['values'][$result['id']]['details'], 'a test activity');
   }
 
   /**
-   *  Test civicrm_activity_get() with no params
+   * Test civicrm_activity_get() with no params
    */
-  function testActivityGetEmpty() {
+  public function testActivityGetEmpty() {
     $result = $this->callAPISuccess('activity', 'get', array());
   }
 
   /**
-   *  Test civicrm_activity_get() with a good activity ID
+   * Test civicrm_activity_get() with a good activity ID
    */
-  function testActivityGetGoodID1() {
-    //  Insert rows in civicrm_activity creating activities 4 and
-    //  13
+  public function testActivityGetGoodID1() {
+    // Insert rows in civicrm_activity creating activities 4 and
+    // 13
     $description = "Function demonstrates getting asignee_contact_id & using it to get the contact";
-    $subfile    = 'ReturnAssigneeContact';
-    $activity   = $this->callAPISuccess('activity', 'create', $this->_params);
+    $subfile = 'ReturnAssigneeContact';
+    $activity = $this->callAPISuccess('activity', 'create', $this->_params);
 
     $contact = $this->callAPISuccess('Contact', 'Create', array(
-                 'first_name' => "The Rock",
-                 'last_name' =>'roccky',
-                 'contact_type' => 'Individual',
-                 'version' => 3,
-                 'api.activity.create' => array(
-                   'id' => $activity['id'], 'assignee_contact_id' => '$value.id',
-                 ),
-               ));
+      'first_name' => "The Rock",
+      'last_name' => 'roccky',
+      'contact_type' => 'Individual',
+      'version' => 3,
+      'api.activity.create' => array(
+        'id' => $activity['id'],
+        'assignee_contact_id' => '$value.id',
+      ),
+    ));
 
     $params = array(
       'activity_id' => $activity['id'],
@@ -526,16 +537,16 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     $this->assertEquals("test activity type id", $result['values'][0]['subject'], 'In line ' . __LINE__);
   }
 
-  /*
-   * test that get functioning does filtering
+  /**
+   * test that get functioning does filtering.
    */
-  function testGetFilter() {
+  public function testGetFilter() {
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => '20110316',
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_name' => 'Test activity type',
@@ -550,9 +561,9 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
 
 
   /**
-   *  Test civicrm_activity_get() with filter target_contact_id
+   * Test civicrm_activity_get() with filter target_contact_id
    */
-  function testActivityGetTargetFilter() {
+  public function testActivityGetTargetFilter() {
     $params = $this->_params;
     $contact1Params = array(
       'first_name' => 'John',
@@ -581,26 +592,34 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     $params['target_contact_id'] = array($contact2 => $contact2);
     $activity = $this->callAPISuccess('Activity', 'Create', $params);
 
-    $activityget   = $this->callAPISuccess('Activity', 'get', array('id' => $activity['id'], 'target_contact_id' => $contact2,'return.target_contact_id' => 1));
+    $activityget = $this->callAPISuccess('Activity', 'get', array(
+      'id' => $activity['id'],
+      'target_contact_id' => $contact2,
+      'return.target_contact_id' => 1,
+    ));
     $this->assertEquals($activity['id'], $activityget['id'], 'In line ' . __LINE__);
     $this->assertEquals($contact2, $activityget['values'][$activityget['id']]['target_contact_id'][0], 'In line ' . __LINE__);
 
-    $activityget   = $this->callAPISuccess('activity', 'get', array('target_contact_id' => $this->_contactID,'return.target_contact_id' => 1,'id' => $activity['id']));
+    $activityget = $this->callAPISuccess('activity', 'get', array(
+      'target_contact_id' => $this->_contactID,
+      'return.target_contact_id' => 1,
+      'id' => $activity['id'],
+    ));
     if ($activityget['count'] > 0) {
       $this->assertNotEquals($contact2, $activityget['values'][$activityget['id']]['target_contact_id'][0], 'In line ' . __LINE__);
     }
   }
 
-  /*
-   * test that get functioning does filtering
+  /**
+   * test that get functioning does filtering.
    */
-  function testGetStatusID() {
+  public function testGetStatusID() {
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => '20110316',
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_name' => 'Test activity type',
@@ -616,23 +635,23 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('Activity', 'Get', array('activity_status_id' => '2'));
     $this->assertEquals(0, $result['count'], 'No activities of status 1 should exist');
     $result = $this->callAPISuccess('Activity', 'Get', array(
-                'version' => $this->_apiversion,
-                'status_id' => '2'));
+      'version' => $this->_apiversion,
+      'status_id' => '2',
+    ));
     $this->assertEquals(0, $result['count'], 'No activities of status 1 should exist');
 
-
   }
 
-  /*
-   * test that get functioning does filtering
+  /**
+   * test that get functioning does filtering.
    */
-  function testGetFilterMaxDate() {
+  public function testGetFilterMaxDate() {
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => '20110101',
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_name' => 'Test activity type',
@@ -643,8 +662,8 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     $params['activity_date_time'] = 20120216;
     $activityTwo = $this->callAPISuccess('Activity', 'Create', $params);
     $result = $this->callAPISuccess('Activity', 'Get', array(
-                'version' => 3,
-              ));
+      'version' => 3,
+    ));
     $description = "demonstrates _low filter (at time of writing doesn't work if contact_id is set";
     $subfile = "DateTimeLow";
     $this->assertEquals(2, $result['count']);
@@ -654,10 +673,10 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
       'sequential' => 1,
     );
     $result = $this->callAPIAndDocument('Activity', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
-    $this->assertEquals(1, $result['count'], 'in line ' . __LINE__);
+    $this->assertEquals(1, $result['count']);
     $description = "demonstrates _high filter (at time of writing doesn't work if contact_id is set";
     $subfile = "DateTimeHigh";
-    $this->assertEquals('2012-02-16 00:00:00', $result['values'][0]['activity_date_time'], 'in line ' . __LINE__);
+    $this->assertEquals('2012-02-16 00:00:00', $result['values'][0]['activity_date_time']);
     $params = array(
       'source_contact_id' => $this->_contactID,
       'version' => 3,
@@ -667,25 +686,25 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     $result = $this->callAPIAndDocument('Activity', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
 
     $this->assertEquals(1, $result['count']);
-    $this->assertEquals('2011-01-01 00:00:00', $result['values'][0]['activity_date_time'], 'in line ' . __LINE__);
+    $this->assertEquals('2011-01-01 00:00:00', $result['values'][0]['activity_date_time']);
 
     $this->callAPISuccess('Activity', 'Delete', array('version' => 3, 'id' => $activityOne['id']));
     $this->callAPISuccess('Activity', 'Delete', array('version' => 3, 'id' => $activityTwo['id']));
   }
 
   /**
-   *  Test civicrm_activity_get() with a good activity ID which
-   *  has associated custom data
+   * Test civicrm_activity_get() with a good activity ID which
+   * has associated custom data
    */
-  function testActivityGetGoodIDCustom() {
+  public function testActivityGetGoodIDCustom() {
     $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
 
     $params = $this->_params;
     $params['custom_' . $ids['custom_field_id']] = "custom string";
 
-    $result = $this->callAPISuccess($this->_entity, 'create', $params);
+    $this->callAPISuccess($this->_entity, 'create', $params);
 
-    //  Retrieve the test value
+    // Retrieve the test value.
     $params = array(
       'activity_type_id' => $this->test_activity_type_value,
       'sequential' => 1,
@@ -701,17 +720,17 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activity_get() with a good activity ID which
-   *  has associated custom data
+   * Test civicrm_activity_get() with a good activity ID which
+   * has associated custom data
    */
-  function testActivityGetContact_idCustom() {
+  public function testActivityGetContact_idCustom() {
     $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
 
     $params = $this->_params;
     $params['custom_' . $ids['custom_field_id']] = "custom string";
 
     $result = $this->callAPISuccess($this->_entity, 'create', $params);
-    //  Retrieve the test value
+    // Retrieve the test value
     $params = array(
       'contact_id' => $this->_params['source_contact_id'],
       'activity_type_id' => $this->test_activity_type_value,
@@ -723,21 +742,21 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
 
     $this->assertEquals($this->test_activity_type_value, $result['values'][0]['activity_type_id'], 'In line ' . __LINE__);
     $this->assertEquals('test activity type id', $result['values'][0]['subject'], 'In line ' . __LINE__);
-    $this->assertEquals($result['values'][0]['id'], $result['id'], 'in line ' . __LINE__);
+    $this->assertEquals($result['values'][0]['id'], $result['id']);
   }
 
   /**
-   * check activity deletion with empty params
+   * Check activity deletion with empty params.
    */
-  function testDeleteActivityForEmptyParams() {
+  public function testDeleteActivityForEmptyParams() {
     $params = array('version' => $this->_apiversion);
-    $result = $this->callAPIFailure('activity', 'delete', $params);
+    $this->callAPIFailure('activity', 'delete', $params);
   }
 
   /**
-   * check activity deletion without activity id
+   * Check activity deletion without activity id.
    */
-  function testDeleteActivityWithoutId() {
+  public function testDeleteActivityWithoutId() {
     $params = array(
       'activity_name' => 'Meeting',
       'version' => $this->_apiversion,
@@ -746,17 +765,17 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   * check activity deletion without activity type
+   * Check activity deletion without activity type.
    */
-  function testDeleteActivityWithoutActivityType() {
+  public function testDeleteActivityWithoutActivityType() {
     $params = array('id' => 1);
     $result = $this->callAPIFailure('activity', 'delete', $params);
   }
 
   /**
-   * check activity deletion with incorrect data
+   * Check activity deletion with incorrect data.
    */
-  function testDeleteActivityWithIncorrectActivityType() {
+  public function testDeleteActivityWithIncorrectActivityType() {
     $params = array(
       'id' => 1,
       'activity_name' => 'Test Activity',
@@ -766,9 +785,9 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   * check activity deletion with correct data
+   * Check activity deletion with correct data.
    */
-  function testDeleteActivity() {
+  public function testDeleteActivity() {
     $result = $this->callAPISuccess('activity', 'create', $this->_params);
     $params = array(
       'id' => $result['id'],
@@ -780,9 +799,9 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   * check if required fields are not passed
+   * Check if required fields are not passed.
    */
-  function testActivityUpdateWithoutRequired() {
+  public function testActivityUpdateWithoutRequired() {
     $params = array(
       'subject' => 'this case should fail',
       'scheduled_date_time' => date('Ymd'),
@@ -794,7 +813,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   /**
    * Test civicrm_activity_update() with non-numeric id
    */
-  function testActivityUpdateWithNonNumericId() {
+  public function testActivityUpdateWithNonNumericId() {
     $params = array(
       'id' => 'lets break it',
       'activity_name' => 'Meeting',
@@ -806,9 +825,9 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   * check with incorrect required fields
+   * Check with incorrect required fields.
    */
-  function testActivityUpdateWithIncorrectContactActivityType() {
+  public function testActivityUpdateWithIncorrectContactActivityType() {
     $params = array(
       'id' => 1,
       'activity_name' => 'Test Activity',
@@ -822,9 +841,9 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activity_update() to update an existing activity
+   * Test civicrm_activity_update() to update an existing activity
    */
-  function testActivityUpdate() {
+  public function testActivityUpdate() {
     $result = $this->callAPISuccess('activity', 'create', $this->_params);
 
     $params = array(
@@ -848,22 +867,22 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activity_update() with valid parameters
-   *  and some custom data
+   * Test civicrm_activity_update() with valid parameters
+   * and some custom data
    */
-  function testActivityUpdateCustom() {
+  public function testActivityUpdateCustom() {
     $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
 
     $params = $this->_params;
 
-    //  Create an activity with custom data
+    // Create an activity with custom data
     //this has been updated from the previous 'old format' function - need to make it work
     $params = array(
       'source_contact_id' => $this->_contactID,
       'subject' => 'Make-it-Happen Meeting',
       'activity_date_time' => '2009-10-18',
       'duration' => 120,
-      'location' => 'Pensulvania',
+      'location' => 'Pennsylvania',
       'details' => 'a test activity to check the update api',
       'status_id' => 1,
       'activity_name' => 'Test activity type',
@@ -873,13 +892,17 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('activity', 'create', $params);
 
     $activityId = $result['id'];
-    $result = $this->callAPISuccess($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'version' => 3, 'id' => $result['id']));
-    $this->assertEquals("custom string", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
-    $this->assertEquals("2009-10-18 00:00:00", $result['values'][$result['id']]['activity_date_time'], ' in line ' . __LINE__);
+    $result = $this->callAPISuccess($this->_entity, 'get', array(
+      'return.custom_' . $ids['custom_field_id'] => 1,
+      'version' => 3,
+      'id' => $result['id'],
+    ));
+    $this->assertEquals("custom string", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']]);
+    $this->assertEquals("2009-10-18 00:00:00", $result['values'][$result['id']]['activity_date_time']);
     $fields = $this->callAPISuccess('activity', 'getfields', array('version' => $this->_apiversion));
     $this->assertTrue(is_array($fields['values']['custom_' . $ids['custom_field_id']]));
 
-    //  Update the activity with custom data
+    // Update the activity with custom data.
     $params = array(
       'id' => $activityId,
       'source_contact_id' => $this->_contactID,
@@ -893,15 +916,19 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     );
     $result = $this->callAPISuccess('Activity', 'Create', $params);
 
-    $result = $this->callAPISuccess($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'version' => 3, 'id' => $result['id']));
-    $this->assertEquals("Updated my test data", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
+    $result = $this->callAPISuccess($this->_entity, 'get', array(
+      'return.custom_' . $ids['custom_field_id'] => 1,
+      'version' => 3,
+      'id' => $result['id'],
+    ));
+    $this->assertEquals("Updated my test data", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']]);
   }
 
   /**
-   *  Test civicrm_activity_update() for core activity fields
-   *  and some custom data
+   * Test civicrm_activity_update() for core activity fields
+   * and some custom data
    */
-  function testActivityUpdateCheckCoreFields() {
+  public function testActivityUpdateCheckCoreFields() {
     $params = $this->_params;
     $contact1Params = array(
       'first_name' => 'John',
@@ -937,7 +964,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
       'version' => $this->_apiversion,
       'id' => $activityId,
     );
-    $result = $this->callAPISuccess($this->_entity, 'get',$getParams );
+    $result = $this->callAPISuccess($this->_entity, 'get', $getParams);
     $assignee = $result['values'][$result['id']]['assignee_contact_id'];
     $target = $result['values'][$result['id']]['target_contact_id'];
     $this->assertEquals(2, count($assignee), ' in line ' . __LINE__);
@@ -984,7 +1011,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
         'return.assignee_contact_id' => 1,
         'return.target_contact_id' => 1,
         'return.source_contact_id' => 1,
-        'id' => $result['id']
+        'id' => $result['id'],
       )
     );
 
@@ -1002,10 +1029,10 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activity_update() where the DB has a date_time
-   *  value and there is none in the update params.
+   * Test civicrm_activity_update() where the DB has a date_time
+   * value and there is none in the update params.
    */
-  function testActivityUpdateNotDate() {
+  public function testActivityUpdateNotDate() {
     $result = $this->callAPISuccess('activity', 'create', $this->_params);
 
     $params = array(
@@ -1028,9 +1055,9 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   * check activity update with status
+   * Check activity update with status.
    */
-  function testActivityUpdateWithStatus() {
+  public function testActivityUpdateWithStatus() {
     $activity = $this->callAPISuccess('activity', 'create', $this->_params);
     $params = array(
       'id' => $activity['id'],
@@ -1048,13 +1075,13 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activity_update() where the source_contact_id
-   *  is not in the update params.
+   * Test civicrm_activity_update() where the source_contact_id
+   * is not in the update params.
    */
-  function testActivityUpdateKeepSource() {
+  public function testActivityUpdateKeepSource() {
     $activity = $this->callAPISuccess('activity', 'create', $this->_params);
-    //  Updating the activity but not providing anything for the source contact
-    //  (It was set as $this->_contactID earlier.)
+    // Updating the activity but not providing anything for the source contact
+    // (It was set as $this->_contactID earlier.)
     $params = array(
       'id' => $activity['id'],
       'subject' => 'Updated Make-it-Happen Meeting',
@@ -1071,59 +1098,64 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
   }
 
   /**
-   *  Test civicrm_activities_contact_get()
+   * Test civicrm_activities_contact_get()
    */
-  function testActivitiesContactGet() {
+  public function testActivitiesContactGet() {
     $activity = $this->callAPISuccess('activity', 'create', $this->_params);
     $activity2 = $this->callAPISuccess('activity', 'create', $this->_params2);
-    //  Get activities associated with contact $this->_contactID
+    // Get activities associated with contact $this->_contactID.
     $params = array(
       'contact_id' => $this->_contactID,
     );
     $result = $this->callAPISuccess('activity', 'get', $params);
 
     $this->assertEquals(2, $result['count'], 'In line ' . __LINE__);
-    $this->assertEquals($this->test_activity_type_value, $result['values'][$activity['id']]['activity_type_id'], 'In line ' . __LINE__);
-    $this->assertEquals('Test activity type', $result['values'][$activity['id']]['activity_name'], 'In line ' . __LINE__);
-    $this->assertEquals('Test activity type', $result['values'][$activity2['id']]['activity_name'], 'In line ' . __LINE__);
+    $this->assertEquals($this->test_activity_type_value, $result['values'][$activity['id']]['activity_type_id']);
+    $this->assertEquals('Test activity type', $result['values'][$activity['id']]['activity_name']);
+    $this->assertEquals('Test activity type', $result['values'][$activity2['id']]['activity_name']);
   }
-  /*
-   * test chained Activity format
+
+  /**
+   * Test chained Activity format.
    */
-  function testchainedActivityGet() {
+  public function testChainedActivityGet() {
 
     $activity = $this->callAPISuccess('Contact', 'Create', array(
-                  'display_name' => "bob brown",
-                  'contact_type' => 'Individual',
-                  'api.activity_type.create' => array(
-                    'weight' => '2',
-                    'label' => 'send out letters',
-                    'filter' => 0,
-                    'is_active' => 1,
-                    'is_optgroup' => 1,
-                    'is_default' => 0,
-                  ), 'api.activity.create' => array('subject' => 'send letter', 'activity_type_id' => '$value.api.activity_type.create.values.0.value'),
-                ));
+      'display_name' => "bob brown",
+      'contact_type' => 'Individual',
+      'api.activity_type.create' => array(
+        'weight' => '2',
+        'label' => 'send out letters',
+        'filter' => 0,
+        'is_active' => 1,
+        'is_optgroup' => 1,
+        'is_default' => 0,
+      ),
+      'api.activity.create' => array(
+        'subject' => 'send letter',
+        'activity_type_id' => '$value.api.activity_type.create.values.0.value',
+      ),
+    ));
 
     $result = $this->callAPISuccess('Activity', 'Get', array(
-                'id' => $activity['id'],
-                'return.assignee_contact_id' => 1,
-                'api.contact.get' => array('api.pledge.get' => 1),
-              ));
+      'id' => $activity['id'],
+      'return.assignee_contact_id' => 1,
+      'api.contact.get' => array('api.pledge.get' => 1),
+    ));
   }
 
   /**
-   *  Test civicrm_activity_contact_get() with invalid Contact Id
+   * Test civicrm_activity_contact_get() with invalid Contact ID.
    */
-  function testActivitiesContactGetWithInvalidContactId() {
+  public function testActivitiesContactGetWithInvalidContactId() {
     $params = array('contact_id' => 'contact');
-    $result = $this->callAPIFailure('activity', 'get', $params);
+    $this->callAPIFailure('activity', 'get', $params);
   }
 
   /**
-   *  Test civicrm_activity_contact_get() with contact having no Activity
+   * Test civicrm_activity_contact_get() with contact having no Activity.
    */
-  function testActivitiesContactGetHavingNoActivity() {
+  public function testActivitiesContactGetHavingNoActivity() {
     $params = array(
       'first_name' => 'dan',
       'last_name' => 'conberg',
@@ -1136,16 +1168,19 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
       'contact_id' => $contact['id'],
     );
     $result = $this->callAPISuccess('activity', 'get', $params);
-    $this->assertEquals($result['count'], 0, 'in line ' . __LINE__);
+    $this->assertEquals($result['count'], 0);
   }
 
-  function testGetFields() {
+  /**
+   * Test getfields function.
+   */
+  public function testGetFields() {
     $params = array('action' => 'create');
     $result = $this->callAPIAndDocument('activity', 'getfields', $params, __FUNCTION__, __FILE__, NULL, NULL, 'getfields');
-    $this->assertTrue(is_array($result['values']), 'get fields doesnt return values array in line ' . __LINE__);
-    // $this->assertTrue(is_array($result['values']['priority_id']['options']));
+    $this->assertTrue(is_array($result['values']), 'get fields doesn\'t return values array');
     foreach ($result['values'] as $key => $value) {
-      $this->assertTrue(is_array($value), $key . " is not an array in line " . __LINE__);
+      $this->assertTrue(is_array($value), $key . " is not an array");
     }
   }
+
 }