Merge remote-tracking branch 'upstream/4.6' into 4.6-master-2015-06-29-23-22-39
[civicrm-core.git] / tests / phpunit / api / v3 / ContributionTest.php
index 37d2f9d92fd27f5f1d7c0e38f4893ad2b54d9fae..2e433ed2f5e477e18bb9ea09b74ea291d264916d 100644 (file)
@@ -504,6 +504,25 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     $this->assertEquals(1, $contribution['count']);
   }
 
+  /**
+   * CRM-16227 introduces invoice_id as a parameter.
+   */
+  public function testGetContributionByInvoice() {
+    $this->callAPISuccess('Contribution', 'create', array_merge($this->_params, array('invoice_id' => 'curly')));
+    $this->callAPISuccess('Contribution', 'create', array_merge($this->_params), array('invoice_id' => 'churlish'));
+    $this->callAPISuccessGetCount('Contribution', array(), 2);
+    $this->callAPISuccessGetSingle('Contribution', array('invoice_id' => 'curly'));
+    // The following don't work. They are the format we are trying to introduce but although the form uses this format
+    // CRM_Contact_BAO_Query::convertFormValues puts them into the other format & the where only supports that.
+    // ideally the where clause would support this format (as it does on contact_BAO_Query) and those lines would
+    // come out of convertFormValues
+    // $this->callAPISuccessGetSingle('Contribution', array('invoice_id' => array('LIKE' => '%ish%')));
+    // $this->callAPISuccessGetSingle('Contribution', array('invoice_id' => array('NOT IN' => array('curly'))));
+    // $this->callAPISuccessGetCount('Contribution', array('invoice_id' => array('LIKE' => '%ly%')), 2);
+    // $this->callAPISuccessGetCount('Contribution', array('invoice_id' => array('IN' => array('curly', 'churlish'))),
+    // 2);
+  }
+
   /**
    * Create test with unique field name on source.
    */