4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.5 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
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';
32 * Class api_v3_MailSettingsTest
34 class api_v3_MailSettingsTest
extends CiviUnitTestCase
{
35 protected $_apiversion = 3;
38 public $DBResetRequired = FALSE;
41 $this->params
= array(
43 'name' => "my mail setting",
44 'domain' => 'setting.com',
45 'local_part' => 'civicrm+',
46 'server' => "localhost",
52 $this->useTransaction(TRUE);
58 public function testCreateMailSettings() {
59 $this->callAPISuccessGetCount('mail_settings', array(), 1);
60 $result = $this->callAPIAndDocument('MailSettings', 'create', $this->params
, __FUNCTION__
, __FILE__
);
61 $this->assertEquals(1, $result['count']);
62 $this->assertNotNull($result['values'][$result['id']]['id']);
63 $this->callAPISuccess('MailSettings', 'delete', array('id' => $result['id']));
64 $this->callAPISuccessGetCount('mail_settings', array(), 1);
68 * Test caches cleared adequately
70 public function testCreateUpdateMailSettings() {
71 $result = $this->callAPISuccess('MailSettings', 'create', $this->params
);
72 $this->assertEquals('setting.com', CRM_Core_BAO_MailSettings
::defaultDomain());
73 $this->callAPISuccess('mail_settings', 'create', array('id' => $result['id'], 'domain' => 'updated.com'));
74 $this->assertEquals('updated.com', CRM_Core_BAO_MailSettings
::defaultDomain());
75 $this->callAPISuccess('MailSettings', 'delete', array('id' => $result['id']));
76 $this->callAPISuccessGetCount('mail_settings', array(), 1);
82 public function testGetMailSettings() {
83 $this->callAPIAndDocument('MailSettings', 'create', $this->params
, __FUNCTION__
, __FILE__
);
84 $result = $this->callAPIAndDocument('MailSettings', 'get', $this->params
, __FUNCTION__
, __FILE__
);
85 $this->assertEquals(1, $result['count']);
86 $this->assertNotNull($result['values'][$result['id']]['id']);
87 $this->callAPISuccess('MailSettings', 'delete', array('id' => $result['id']));
88 $this->callAPISuccessGetCount('mail_settings', array(), 1);
91 public function testDeleteMailSettings() {
92 $this->callAPIAndDocument('MailSettings', 'create', $this->params
, __FUNCTION__
, __FILE__
);
93 $entity = $this->callAPISuccess('MailSettings', 'get', $this->params
);
94 $this->assertEquals('setting.com', $entity['values'][$entity['id']]['domain']);
95 $this->callAPIAndDocument('MailSettings', 'delete', array('id' => $entity['id']), __FUNCTION__
, __FILE__
);
96 $checkDeleted = $this->callAPISuccess('MailSettings', 'get', array());
97 $this->assertEquals('EXAMPLE.ORG', $checkDeleted['values'][$checkDeleted['id']]['domain']);
101 * Test chained delete
103 public function testGetMailSettingsChainDelete() {
104 $description = "demonstrates get + delete in the same call";
105 $subFile = 'ChainedGetDelete';
107 'title' => "MailSettings title",
108 'api.MailSettings.delete' => 1,
110 $this->callAPISuccess('MailSettings', 'create', $this->params
);
111 $this->callAPIAndDocument('MailSettings', 'get', $params, __FUNCTION__
, __FILE__
, $description, $subFile);
112 $this->assertEquals(0, $this->callAPISuccess('MailSettings', 'getcount', array()));