Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | // $Id$ | |
3 | ||
4 | ||
5 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
6 | class api_v3_MailSettingsTest extends CiviUnitTestCase { | |
7 | protected $_apiversion; | |
8 | protected $params; | |
9 | protected $id; | |
430ae6dd TO |
10 | public $DBResetRequired = FALSE; |
11 | ||
12 | function setUp() { | |
6a488035 TO |
13 | $this->_apiversion = 3; |
14 | $this->params = array( | |
15 | 'domain_id' => 1, | |
16 | 'name' => "my mail setting", | |
17 | 'domain' => 'setting.com', | |
18 | 'local_part' => 'civicrm+', | |
19 | 'server' => "localhost", | |
20 | 'username' => 'sue', | |
21 | 'password' => 'pass', | |
22 | 'version' => $this->_apiversion, | |
23 | ); | |
24 | parent::setUp(); | |
25 | } | |
26 | ||
27 | function tearDown() {} | |
28 | ||
29 | public function testCreateMailSettings() { | |
30 | $result = civicrm_api('MailSettings', 'create', $this->params); | |
31 | $this->documentMe($this->params, $result, __FUNCTION__, __FILE__); | |
32 | $this->assertAPISuccess($result, 'In line ' . __LINE__); | |
33 | $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); | |
34 | $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__); | |
35 | } | |
36 | ||
37 | public function testGetMailSettings() { | |
38 | ||
39 | $result = civicrm_api('MailSettings', 'get', $this->params); | |
40 | $this->documentMe($this->params, $result, __FUNCTION__, __FILE__); | |
41 | $this->assertAPISuccess($result, 'In line ' . __LINE__); | |
42 | $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); | |
43 | $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__); | |
44 | $this->id = $result['id']; | |
45 | } | |
46 | ||
47 | public function testDeleteMailSettings() { | |
48 | $entity = civicrm_api('MailSettings', 'get', $this->params); | |
49 | $this->assertEquals('setting.com', $entity['values'][$entity['id']]['domain'], 'In line ' . __LINE__); | |
50 | ||
51 | $result = civicrm_api('MailSettings', 'delete', array('version' => 3, 'id' => $entity['id'])); | |
52 | $this->documentMe($this->params, $result, __FUNCTION__, __FILE__); | |
53 | $this->assertAPISuccess($result, 'In line ' . __LINE__); | |
54 | $checkDeleted = civicrm_api('MailSettings', 'get', array( | |
55 | 'version' => 3, | |
56 | )); | |
57 | $this->assertEquals('EXAMPLE.ORG', $checkDeleted['values'][$checkDeleted['id']]['domain'], 'In line ' . __LINE__); | |
58 | } | |
59 | ||
60 | public function testGetMailSettingsChainDelete() { | |
61 | $description = "demonstrates get + delete in the same call"; | |
62 | $subfile = 'ChainedGetDelete'; | |
63 | $params = array( | |
64 | 'version' => 3, | |
65 | 'title' => "MailSettings title", | |
66 | 'api.MailSettings.delete' => 1, | |
67 | ); | |
68 | $result = civicrm_api('MailSettings', 'create', $this->params); | |
69 | $result = civicrm_api('MailSettings', 'get', $params); | |
70 | $this->documentMe($params, $result, __FUNCTION__, __FILE__, $description, $subfile); | |
71 | $this->assertAPISuccess($result, 'In line ' . __LINE__); | |
72 | $this->assertEquals(0, civicrm_api('MailSettings', 'getcount', array('version' => 3)), 'In line ' . __LINE__); | |
73 | } | |
74 | } | |
75 |