CRM-15855 - Allow mailings to be saved (but not sent) without name+subject.
[civicrm-core.git] / tests / phpunit / api / v3 / PriceSetTest.php
index 1664144095ad882a0364097f63a1d01578456836..804235483c7a566070317569eae3866083f4e2af 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
 | CiviCRM version 4.6                                                |
@@ -24,7 +23,7 @@
 | GNU Affero General Public License or the licensing of CiviCRM,     |
 | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
 +--------------------------------------------------------------------+
-*/
+ */
 
 require_once 'CiviTest/CiviUnitTestCase.php';
 
@@ -39,10 +38,11 @@ class api_v3_PriceSetTest extends CiviUnitTestCase {
   protected $_entity = 'price_set';
 
   public $DBResetRequired = TRUE;
+
   public function setUp() {
     parent::setUp();
     $this->_params = array(
-#     [domain_id] =>
+      #     [domain_id] =>
       'name' => 'default_goat_priceset',
       'title' => 'Goat accessories',
       'is_active' => 1,
@@ -55,11 +55,10 @@ class api_v3_PriceSetTest extends CiviUnitTestCase {
     );
   }
 
-  function tearDown() {
+  public function tearDown() {
   }
 
   /**
-   *
    */
   public function testCreatePriceSet() {
     $result = $this->callAPIAndDocument($this->_entity, 'create', $this->_params, __FUNCTION__, __FILE__);
@@ -68,6 +67,29 @@ class api_v3_PriceSetTest extends CiviUnitTestCase {
     $this->getAndCheck($this->_params, $result['id'], $this->_entity);
   }
 
+  /**
+   * Test for creating price sets used for both events and contributions.
+   */
+  public function testCreatePriceSetForEventAndContribution() {
+    // Create the price set
+    $createParams = array(
+      'name' => 'some_price_set',
+      'title' => 'Some Price Set',
+      'is_active' => 1,
+      'financial_type_id' => 1,
+      'extends' => array(1, 2),
+    );
+    $createResult = $this->callAPIAndDocument($this->_entity, 'create', $createParams, __FUNCTION__, __FILE__);
+
+    // Get priceset we just created.
+    $result = $this->callAPISuccess($this->_entity, 'getSingle', array(
+      'id' => $createResult['id'],
+    ));
+
+    // Count the number of items in 'extends'.
+    $this->assertEquals(2, count($result['extends']));
+  }
+
   /**
    * Check that no name doesn't cause failure
    */
@@ -78,7 +100,6 @@ class api_v3_PriceSetTest extends CiviUnitTestCase {
   }
 
   /**
-   *
    */
   public function testGetBasicPriceSet() {
     $getParams = array(
@@ -126,10 +147,10 @@ class api_v3_PriceSetTest extends CiviUnitTestCase {
   }
 
   public static function setUpBeforeClass() {
-      // put stuff here that should happen before all tests in this unit
+    // put stuff here that should happen before all tests in this unit
   }
 
-  public static function tearDownAfterClass(){
+  public static function tearDownAfterClass() {
     $tablesToTruncate = array(
       'civicrm_contact',
       'civicrm_contribution',
@@ -137,5 +158,5 @@ class api_v3_PriceSetTest extends CiviUnitTestCase {
     $unitTest = new CiviUnitTestCase();
     $unitTest->quickCleanup($tablesToTruncate);
   }
-}
 
+}