3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviUnitTestCase.php';
31 * Test class for Batch API - civicrm_batch_*
33 * @package CiviCRM_APIv3
35 class api_v3_BatchTest
extends CiviUnitTestCase
{
37 protected $_params = array();
38 protected $_entity = 'batch';
41 * Sets up the fixture, for example, opens a network connection.
43 * This method is called before a test is executed.
45 protected function setUp() {
47 $this->useTransaction(TRUE);
51 * Test civicrm_batch_get - success expected.
53 public function testGet() {
55 'id' => $this->batchCreate(),
57 $result = $this->callAPIAndDocument('batch', 'get', $params, __FUNCTION__
, __FILE__
);
58 $this->assertEquals($params['id'], $result['id']);
62 * Test civicrm_batch_create - success expected.
64 public function testCreate() {
66 'name' => 'New_Batch_03',
67 'title' => 'New Batch 03',
68 'description' => 'This is description for New Batch 03',
74 $result = $this->callAPIAndDocument('batch', 'create', $params, __FUNCTION__
, __FILE__
);
75 $this->assertNotNull($result['id']);
76 $this->getAndCheck($params, $result['id'], $this->_entity
);
80 * Test civicrm_batch_create with id.
82 public function testUpdate() {
84 'name' => 'New_Batch_04',
85 'title' => 'New Batch 04',
86 'description' => 'This is description for New Batch 04',
89 'id' => $this->batchCreate(),
92 $result = $this->callAPIAndDocument('batch', 'create', $params, __FUNCTION__
, __FILE__
);
93 $this->assertNotNull($result['id']);
94 $this->getAndCheck($params, $result['id'], $this->_entity
);
98 * Test civicrm_batch_delete using the old $params['batch_id'] syntax.
100 public function testBatchDeleteOldSyntax() {
101 $batchID = $this->batchCreate();
103 'batch_id' => $batchID,
105 $result = $this->callAPISuccess('batch', 'delete', $params);
109 * Test civicrm_batch_delete using the new $params['id'] syntax.
111 public function testBatchDeleteCorrectSyntax() {
112 $batchID = $this->batchCreate();
116 $result = $this->callAPIAndDocument('batch', 'delete', $params, __FUNCTION__
, __FILE__
);