Commit | Line | Data |
---|---|---|
6a488035 TO |
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; function setUp() { | |
12 | $this->_apiversion = 3; | |
13 | $this->params = array( | |
14 | 'version' => 3, | |
15 | 'title' => "campaign title", | |
16 | 'description' => "Call people, ask for money", | |
17 | 'created_date' => 'first sat of July 2008', | |
18 | ); | |
19 | parent::setUp(); | |
20 | } | |
21 | ||
22 | function tearDown() {} | |
23 | ||
24 | public function testCreateCampaign() { | |
25 | $description = "Create a campaign - Note use of relative dates here http://www.php.net/manual/en/datetime.formats.relative.php"; | |
26 | $result = civicrm_api('campaign', 'create', $this->params); | |
27 | $this->documentMe($this->params, $result, __FUNCTION__, __FILE__, $description); | |
28 | $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__); | |
29 | $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); | |
30 | $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__); | |
31 | $this->getAndCheck(array_merge($this->params, array('created_date' => '2008-07-05 00:00:00')), $result['id'], 'campaign', TRUE); | |
32 | } | |
33 | ||
34 | public function testGetCampaign() { | |
35 | $result = civicrm_api('campaign', 'create', $this->params); | |
36 | $result = civicrm_api('campaign', 'get', ($this->params)); | |
37 | $this->documentMe($this->params, $result, __FUNCTION__, __FILE__); | |
38 | $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__); | |
39 | $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); | |
40 | $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__); | |
41 | $this->id = $result['id']; | |
42 | } | |
43 | ||
44 | public function testDeleteCampaign() { | |
45 | $entity = civicrm_api('campaign', 'get', ($this->params)); | |
46 | $delete = array('version' => 3, 'id' => $entity['id']); | |
47 | $result = civicrm_api('campaign', 'delete', $delete); | |
48 | $this->documentMe($delete, $result, __FUNCTION__, __FILE__); | |
49 | $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__); | |
50 | ||
51 | $checkDeleted = civicrm_api('campaign', 'get', array( | |
52 | 'version' => 3, | |
53 | )); | |
54 | $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__); | |
55 | } | |
56 | } | |
57 |