4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
29 require_once 'CiviTest/CiviUnitTestCase.php';
30 class api_v3_MailSettingsTest
extends CiviUnitTestCase
{
31 protected $_apiversion;
34 public $DBResetRequired = FALSE;
37 $this->_apiversion
= 3;
38 $this->params
= array(
40 'name' => "my mail setting",
41 'domain' => 'setting.com',
42 'local_part' => 'civicrm+',
43 'server' => "localhost",
46 'version' => $this->_apiversion
,
51 function tearDown() {}
53 public function testCreateMailSettings() {
54 $result = civicrm_api('MailSettings', 'create', $this->params
);
55 $this->documentMe($this->params
, $result, __FUNCTION__
, __FILE__
);
56 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
57 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
58 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__
);
61 public function testGetMailSettings() {
63 $result = civicrm_api('MailSettings', 'get', $this->params
);
64 $this->documentMe($this->params
, $result, __FUNCTION__
, __FILE__
);
65 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
66 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
67 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__
);
68 $this->id
= $result['id'];
71 public function testDeleteMailSettings() {
72 $entity = civicrm_api('MailSettings', 'get', $this->params
);
73 $this->assertEquals('setting.com', $entity['values'][$entity['id']]['domain'], 'In line ' . __LINE__
);
75 $result = civicrm_api('MailSettings', 'delete', array('version' => 3, 'id' => $entity['id']));
76 $this->documentMe($this->params
, $result, __FUNCTION__
, __FILE__
);
77 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
78 $checkDeleted = civicrm_api('MailSettings', 'get', array(
81 $this->assertEquals('EXAMPLE.ORG', $checkDeleted['values'][$checkDeleted['id']]['domain'], 'In line ' . __LINE__
);
84 public function testGetMailSettingsChainDelete() {
85 $description = "demonstrates get + delete in the same call";
86 $subfile = 'ChainedGetDelete';
89 'title' => "MailSettings title",
90 'api.MailSettings.delete' => 1,
92 $result = civicrm_api('MailSettings', 'create', $this->params
);
93 $result = civicrm_api('MailSettings', 'get', $params);
94 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
, $description, $subfile);
95 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
96 $this->assertEquals(0, civicrm_api('MailSettings', 'getcount', array('version' => 3)), 'In line ' . __LINE__
);