CRM-13014 support userLoginFinalize() for UF classes (fix civimobile)
[civicrm-core.git] / tests / phpunit / api / v3 / CampaignTest.php
1 <?php
2 // $Id$
3
4
5 require_once 'CiviTest/CiviUnitTestCase.php';
6 class api_v3_CampaignTest extends CiviUnitTestCase {
7 protected $_apiversion;
8 protected $params;
9 protected $id;
10 public $_eNoticeCompliant = TRUE;
11 public $DBResetRequired = FALSE;
12
13 function setUp() {
14 $this->_apiversion = 3;
15 $this->params = array(
16 'version' => 3,
17 'title' => "campaign title",
18 'description' => "Call people, ask for money",
19 'created_date' => 'first sat of July 2008',
20 );
21 parent::setUp();
22 }
23
24 function tearDown() {}
25
26 public function testCreateCampaign() {
27 $description = "Create a campaign - Note use of relative dates here http://www.php.net/manual/en/datetime.formats.relative.php";
28 $result = civicrm_api('campaign', 'create', $this->params);
29 $this->documentMe($this->params, $result, __FUNCTION__, __FILE__, $description);
30 $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
31 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
32 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
33 $this->getAndCheck(array_merge($this->params, array('created_date' => '2008-07-05 00:00:00')), $result['id'], 'campaign', TRUE);
34 }
35
36 public function testGetCampaign() {
37 $result = civicrm_api('campaign', 'create', $this->params);
38 $result = civicrm_api('campaign', 'get', ($this->params));
39 $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
40 $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
41 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
42 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
43 $this->id = $result['id'];
44 }
45
46 public function testDeleteCampaign() {
47 $entity = civicrm_api('campaign', 'get', ($this->params));
48 $delete = array('version' => 3, 'id' => $entity['id']);
49 $result = civicrm_api('campaign', 'delete', $delete);
50 $this->documentMe($delete, $result, __FUNCTION__, __FILE__);
51 $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
52
53 $checkDeleted = civicrm_api('campaign', 'get', array(
54 'version' => 3,
55 ));
56 $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__);
57 }
58 }
59