test failure fix2
[civicrm-core.git] / tests / phpunit / api / v3 / LineItemTest.php
index 96f1b1b05275d7f9c26367b95471f46d3e97e6b0..a32a05db7cbc2910304e7ea0e9050b4748173368 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
-| CiviCRM version 4.5                                                |
+| CiviCRM version 4.6                                                |
 +--------------------------------------------------------------------+
 | Copyright CiviCRM LLC (c) 2004-2014                                |
 +--------------------------------------------------------------------+
@@ -37,13 +37,14 @@ class api_v3_LineItemTest extends CiviUnitTestCase {
   protected $id = 0;
   protected $contactIds = array();
   protected $_entity = 'line_item';
-  protected $contribution_result = null;
+  protected $contribution_result = NULL;
 
   public $DBResetRequired = TRUE;
   protected $_financialTypeId = 1;
 
   public function setUp() {
     parent::setUp();
+    $this->useTransaction(TRUE);
     $this->_individualId = $this->individualCreate();
     $contributionParams = array(
       'contact_id' => $this->_individualId,
@@ -56,7 +57,7 @@ class api_v3_LineItemTest extends CiviUnitTestCase {
       'source' => 'SSF',
       'contribution_status_id' => 1,
     );
-    $contribution = $this->callAPISuccess('contribution','create', $contributionParams);
+    $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams);
     $this->params = array(
       'price_field_value_id' => 1,
       'price_field_id' => 1,
@@ -68,26 +69,7 @@ class api_v3_LineItemTest extends CiviUnitTestCase {
     );
   }
 
-  function tearDown() {
-
-    foreach ($this->contactIds as $id) {
-      $this->callAPISuccess('contact', 'delete', array('id' => $id));
-    }
-    $this->quickCleanup(
-        array(
-            'civicrm_contact',
-            'civicrm_contribution',
-            'civicrm_line_item',
-        )
-    );
-  }
-
   public function testCreateLineItem() {
-    $this->quickCleanup(
-        array(
-            'civicrm_line_item',
-        )
-    );
     $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params + array('debug' => 1), __FUNCTION__, __FILE__);
     $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
     $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
@@ -103,7 +85,8 @@ class api_v3_LineItemTest extends CiviUnitTestCase {
   }
 
   public function testDeleteLineItem() {
-    $getParams = array(        'entity_table' => 'civicrm_contribution',
+    $getParams = array(
+      'entity_table' => 'civicrm_contribution',
     );
     $getResult = $this->callAPISuccess($this->_entity, 'get', $getParams);
     $deleteParams = array('id' => $getResult['id']);
@@ -113,23 +96,8 @@ class api_v3_LineItemTest extends CiviUnitTestCase {
   }
 
   public function testGetFieldsLineItem() {
-    $result = $this->callAPISuccess($this->_entity, 'getfields', array('action' => 'create',));
+    $result = $this->callAPISuccess($this->_entity, 'getfields', array('action' => 'create'));
     $this->assertEquals(1, $result['values']['entity_id']['api.required']);
   }
 
-  public static function setUpBeforeClass() {
-      // put stuff here that should happen before all tests in this unit
-  }
-
-  public static function tearDownAfterClass(){
-    $tablesToTruncate = array(
-      'civicrm_contact',
-      'civicrm_financial_type',
-      'civicrm_contribution',
-      'civicrm_line_item',
-    );
-    $unitTest = new CiviUnitTestCase();
-    $unitTest->quickCleanup($tablesToTruncate);
-  }
 }
-