* Create a batch of external API calls which can
* be executed concurrently.
*
- * @code
+ * ```
* $calls = $this->createExternalAPI()
* ->addCall('Contact', 'get', ...)
* ->addCall('Contact', 'get', ...)
* ...
* ->run()
* ->getResults();
- * @endcode
+ * ```
*
* @return \Civi\API\ExternalBatch
* @throws PHPUnit_Framework_SkippedTestError
*
* @return int
* id of created pledge
+ *
+ * @throws \CRM_Core_Exception
*/
public function pledgeCreate($params) {
$params = array_merge([
* Delete contribution.
*
* @param int $pledgeId
+ *
+ * @throws \CRM_Core_Exception
*/
public function pledgeDelete($pledgeId) {
$params = [
}
}
+ /**
+ * Generic create test.
+ *
+ * @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ */
+ protected function basicCreateTest(int $version) {
+ $this->_apiversion = $version;
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params, __FUNCTION__, __FILE__);
+ $this->assertEquals(1, $result['count']);
+ $this->assertNotNull($result['values'][$result['id']]['id']);
+ $this->getAndCheck($this->params, $result['id'], $this->_entity);
+ }
+
+ /**
+ * Generic delete test.
+ *
+ * @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ */
+ protected function basicDeleteTest($version) {
+ $this->_apiversion = $version;
+ $result = $this->callAPISuccess($this->_entity, 'create', $this->params);
+ $deleteParams = ['id' => $result['id']];
+ $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__);
+ $checkDeleted = $this->callAPISuccess($this->_entity, 'get', []);
+ $this->assertEquals(0, $checkDeleted['count']);
+ }
+
}