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 = 3;
34 public $DBResetRequired = FALSE;
37 $this->params
= array(
39 'name' => "my mail setting",
40 'domain' => 'setting.com',
41 'local_part' => 'civicrm+',
42 'server' => "localhost",
49 function tearDown() {}
51 public function testCreateMailSettings() {
52 $result = $this->callAPIAndDocument('MailSettings', 'create', $this->params
, __FUNCTION__
, __FILE__
);
53 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
54 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__
);
57 public function testGetMailSettings() {
59 $result = $this->callAPIAndDocument('MailSettings', 'get', $this->params
, __FUNCTION__
, __FILE__
);
60 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
61 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__
);
64 public function testDeleteMailSettings() {
65 $entity = $this->callAPISuccess('MailSettings', 'get', $this->params
);
66 $this->assertEquals('setting.com', $entity['values'][$entity['id']]['domain'], 'In line ' . __LINE__
);
68 $result = $this->callAPIAndDocument('MailSettings', 'delete', array('id' => $entity['id']), __FUNCTION__
, __FILE__
);
69 $checkDeleted = $this->callAPISuccess('MailSettings', 'get', array());
70 $this->assertEquals('EXAMPLE.ORG', $checkDeleted['values'][$checkDeleted['id']]['domain'], 'In line ' . __LINE__
);
73 public function testGetMailSettingsChainDelete() {
74 $description = "demonstrates get + delete in the same call";
75 $subfile = 'ChainedGetDelete';
77 'title' => "MailSettings title",
78 'api.MailSettings.delete' => 1,
80 $result = $this->callAPISuccess('MailSettings', 'create', $this->params
);
81 $result = $this->callAPIAndDocument('MailSettings', 'get', $params, __FUNCTION__
, __FILE__
, $description, $subfile);
82 $this->assertEquals(0, $this->callAPISuccess('MailSettings', 'getcount', array()), 'In line ' . __LINE__
);