3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class api_v3_CampaignTest
16 class api_v3_CampaignTest
extends CiviUnitTestCase
{
20 public $DBResetRequired = FALSE;
22 public function setUp() {
24 'title' => "campaign title",
25 'description' => "Call people, ask for money",
26 'created_date' => 'first sat of July 2008',
29 $this->useTransaction(TRUE);
34 * @dataProvider versionThreeAndFour
36 public function testCreateCampaign($version) {
37 $this->_apiversion
= $version;
38 $description = "Create a campaign - Note use of relative dates here:
39 @link http://www.php.net/manual/en/datetime.formats.relative.php.";
40 $result = $this->callAPIAndDocument('campaign', 'create', $this->params
, __FUNCTION__
, __FILE__
, $description);
41 $this->assertEquals(1, $result['count']);
42 $this->assertNotNull($result['values'][$result['id']]['id']);
43 $this->getAndCheck(array_merge($this->params
, ['created_date' => '2008-07-05 00:00:00']), $result['id'], 'campaign', TRUE);
48 * @dataProvider versionThreeAndFour
50 public function testGetCampaign($version) {
51 $this->_apiversion
= $version;
52 $result = $this->callAPISuccess('campaign', 'create', $this->params
);
53 $result = $this->callAPIAndDocument('campaign', 'get', $this->params
, __FUNCTION__
, __FILE__
);
54 $this->assertEquals(1, $result['count']);
55 $this->assertNotNull($result['values'][$result['id']]['id']);
60 * @dataProvider versionThreeAndFour
62 public function testDeleteCampaign($version) {
63 $this->_apiversion
= $version;
64 $this->callAPISuccess('campaign', 'create', $this->params
);
65 $entity = $this->callAPISuccess('campaign', 'get', ($this->params
));
66 $delete = ['id' => $entity['id']];
67 $result = $this->callAPIAndDocument('campaign', 'delete', $delete, __FUNCTION__
, __FILE__
);
69 $checkDeleted = $this->callAPISuccess('campaign', 'get', []);
70 $this->assertEquals(0, $checkDeleted['count']);