INFRA-132 - tests/ - PHPStorm cleanup
[civicrm-core.git] / tests / phpunit / api / v3 / NoteTest.php
index 76eb1bb1f4e1b230253a2570869ffcfe028ceca1..548669c9516ac90f3a24b713ce4cd11ee3ef6bef 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -39,30 +39,12 @@ class api_v3_NoteTest extends CiviUnitTestCase {
   protected $_noteID;
   protected $_note;
 
-
-  /**
-   *
-   */
-  function __construct() {
-    parent::__construct();
-  }
-
-  /**
-   * @return array
-   */
-  function get_info() {
-    return array(
-      'name' => 'Note Create',
-      'description' => 'Test all Note Create API methods.',
-      'group' => 'CiviCRM API Tests',
-    );
-  }
-
-  function setUp() {
+  public function setUp() {
 
     $this->_apiversion = 3;
     //  Connect to the database
     parent::setUp();
+    $this->useTransaction(TRUE);
 
     $this->_contactID = $this->organizationCreate(NULL);
 
@@ -72,33 +54,27 @@ class api_v3_NoteTest extends CiviUnitTestCase {
       'note' => 'Hello!!! m testing Note',
       'contact_id' => $this->_contactID,
       'modified_date' => '2011-01-31',
-      'subject' => 'Test Note',    );
+      'subject' => 'Test Note',
+    );
     $this->_note = $this->noteCreate($this->_contactID);
     $this->_noteID = $this->_note['id'];
   }
 
-  function tearDown() {
-    $tablesToTruncate = array(
-      'civicrm_note', 'civicrm_contact',
-    );
-    $this->quickCleanup($tablesToTruncate);
-  }
-
   ///////////////// civicrm_note_get methods
 
   /**
-   * check retrieve note with empty parameter array
+   * Check retrieve note with empty parameter array
    * Error expected
    */
-  function testGetWithEmptyParams() {
+  public function testGetWithEmptyParams() {
     $this->callAPISuccess('note', 'get', array());
   }
 
   /**
-   * check retrieve note with missing patrameters
+   * Check retrieve note with missing patrameters
    * Error expected
    */
-  function testGetWithoutEntityId() {
+  public function testGetWithoutEntityId() {
     $params = array(
       'entity_table' => 'civicrm_contact',
     );
@@ -106,9 +82,9 @@ class api_v3_NoteTest extends CiviUnitTestCase {
   }
 
   /**
-   * check civicrm_note_get
+   * Check civicrm_note_get
    */
-  function testGet() {
+  public function testGet() {
     $entityId = $this->_noteID;
     $params = array(
       'entity_table' => 'civicrm_contact',
@@ -124,7 +100,7 @@ class api_v3_NoteTest extends CiviUnitTestCase {
    * Check create with empty parameter array
    * Error Expected
    */
-  function testCreateWithEmptyNoteField() {
+  public function testCreateWithEmptyNoteField() {
     $this->_params['note'] = "";
     $result = $this->callAPIFailure('note', 'create', $this->_params,
       'Mandatory key(s) missing from params array: note');
@@ -134,7 +110,7 @@ class api_v3_NoteTest extends CiviUnitTestCase {
    * Check create with partial params
    * Error expected
    */
-  function testCreateWithoutEntityId() {
+  public function testCreateWithoutEntityId() {
     unset($this->_params['entity_id']);
     $result = $this->callAPIFailure('note', 'create', $this->_params,
       'Mandatory key(s) missing from params array: entity_id');
@@ -144,7 +120,7 @@ class api_v3_NoteTest extends CiviUnitTestCase {
    * Check create with partially empty params
    * Error expected
    */
-  function testCreateWithEmptyEntityId() {
+  public function testCreateWithEmptyEntityId() {
     $this->_params['entity_id'] = "";
     $result = $this->callAPIFailure('note', 'create', $this->_params,
       'Mandatory key(s) missing from params array: entity_id');
@@ -153,7 +129,7 @@ class api_v3_NoteTest extends CiviUnitTestCase {
   /**
    * Check civicrm_note_create
    */
-  function testCreate() {
+  public function testCreate() {
 
     $result = $this->callAPIAndDocument('note', 'create', $this->_params, __FUNCTION__, __FILE__);
     $this->assertEquals($result['values'][$result['id']]['note'], 'Hello!!! m testing Note', 'in line ' . __LINE__);
@@ -161,11 +137,12 @@ class api_v3_NoteTest extends CiviUnitTestCase {
 
     $this->assertArrayHasKey('id', $result);
     $note = array(
-      'id' => $result['id'],    );
+      'id' => $result['id'],
+    );
     $this->noteDelete($note);
   }
 
-  function testCreateWithApostropheInString() {
+  public function testCreateWithApostropheInString() {
     $params = array(
       'entity_table' => 'civicrm_contact',
       'entity_id' => $this->_contactID,
@@ -173,7 +150,8 @@ class api_v3_NoteTest extends CiviUnitTestCase {
       'contact_id' => $this->_contactID,
       'modified_date' => '2011-01-31',
       'subject' => "With a '",
-      'sequential' => 1,    );
+      'sequential' => 1,
+    );
     $result = $this->callAPISuccess('Note', 'Create', $params);
     $this->assertAPISuccess($result, 'in line ' . __LINE__);
     $this->assertEquals($result['values'][0]['note'], "Hello!!! ' testing Note", 'in line ' . __LINE__);
@@ -182,20 +160,22 @@ class api_v3_NoteTest extends CiviUnitTestCase {
 
     //CleanUP
     $note = array(
-      'id' => $result['id'],    );
+      'id' => $result['id'],
+    );
     $this->noteDelete($note);
   }
 
   /**
    * Check civicrm_note_create - tests used of default set to now
    */
-  function testCreateWithoutModifiedDate() {
+  public function testCreateWithoutModifiedDate() {
     unset($this->_params['modified_date']);
     $apiResult = $this->callAPISuccess('note', 'create', $this->_params);
     $this->assertAPISuccess($apiResult);
     $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($apiResult['values'][$apiResult['id']]['modified_date'])));
     $this->noteDelete(array(
-      'id' => $apiResult['id'],      ));
+      'id' => $apiResult['id'],
+    ));
   }
 
 
@@ -206,7 +186,7 @@ class api_v3_NoteTest extends CiviUnitTestCase {
    * Please don't copy & paste this - is of marginal value
    * better to put time into the function on Syntax Conformance class that tests this
    */
-  function testUpdateWithEmptyParams() {
+  public function testUpdateWithEmptyParams() {
     $note = $this->callAPIFailure('note', 'create', array());
   }
 
@@ -214,10 +194,11 @@ class api_v3_NoteTest extends CiviUnitTestCase {
    * Check update with missing parameter (contact id)
    * Error expected
    */
-  function testUpdateWithoutContactId() {
+  public function testUpdateWithoutContactId() {
     $params = array(
       'entity_id' => $this->_contactID,
-      'entity_table' => 'civicrm_contact',    );
+      'entity_table' => 'civicrm_contact',
+    );
     $note = $this->callAPIFailure('note', 'create', $params,
       'Mandatory key(s) missing from params array: note'
     );
@@ -226,12 +207,13 @@ class api_v3_NoteTest extends CiviUnitTestCase {
   /**
    * Check civicrm_note_update
    */
-  function testUpdate() {
+  public function testUpdate() {
     $params = array(
       'id' => $this->_noteID,
       'contact_id' => $this->_contactID,
       'note' => 'Note1',
-      'subject' => 'Hello World',    );
+      'subject' => 'Hello World',
+    );
 
     //Update Note
     $this->callAPISuccess('note', 'create', $params);
@@ -250,7 +232,7 @@ class api_v3_NoteTest extends CiviUnitTestCase {
    * Check delete with empty parametes array
    * Error expected
    */
-  function testDeleteWithEmptyParams() {
+  public function testDeleteWithEmptyParams() {
     $deleteNote = $this->callAPIFailure('note', 'delete', array(), 'Mandatory key(s) missing from params array: id');
   }
 
@@ -258,18 +240,17 @@ class api_v3_NoteTest extends CiviUnitTestCase {
    * Check delete with wrong id
    * Error expected
    */
-  function testDeleteWithWrongID() {
+  public function testDeleteWithWrongID() {
     $params = array(
       'id' => 0,
     );
-    $deleteNote = $this->callAPIFailure('note', 'delete', $params
-      , 'Mandatory key(s) missing from params array: id');
+    $deleteNote = $this->callAPIFailure('note', 'delete', $params, 'Mandatory key(s) missing from params array: id');
   }
 
   /**
    * Check civicrm_note_delete
    */
-  function testDelete() {
+  public function testDelete() {
     $additionalNote = $this->noteCreate($this->_contactID);
 
     $params = array(
@@ -289,4 +270,3 @@ function testNoteCreateExample() {
   $expectedResult = UF_match_get_expectedresult();
   $this->assertEquals($result, $expectedResult);
 }
-