Syntax conformance test fixes
[civicrm-core.git] / tests / phpunit / api / v3 / MailSettingsTest.php
CommitLineData
6a488035 1<?php
6a488035 2
b6708aeb 3/*
4 +--------------------------------------------------------------------+
06a1bc01 5| CiviCRM version 4.5 |
b6708aeb 6+--------------------------------------------------------------------+
06a1bc01 7| Copyright CiviCRM LLC (c) 2004-2014 |
b6708aeb 8+--------------------------------------------------------------------+
9| This file is a part of CiviCRM. |
10| |
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. |
14| |
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. |
19| |
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+--------------------------------------------------------------------+
27*/
6a488035
TO
28
29require_once 'CiviTest/CiviUnitTestCase.php';
e9479dcf
EM
30
31/**
32 * Class api_v3_MailSettingsTest
33 */
6a488035 34class api_v3_MailSettingsTest extends CiviUnitTestCase {
50debe3c 35 protected $_apiversion = 3;
6a488035
TO
36 protected $params;
37 protected $id;
430ae6dd
TO
38 public $DBResetRequired = FALSE;
39
40 function setUp() {
6a488035
TO
41 $this->params = array(
42 'domain_id' => 1,
43 'name' => "my mail setting",
44 'domain' => 'setting.com',
45 'local_part' => 'civicrm+',
46 'server' => "localhost",
47 'username' => 'sue',
48 'password' => 'pass',
6a488035
TO
49 );
50 parent::setUp();
51 }
52
53 function tearDown() {}
54
55 public function testCreateMailSettings() {
50debe3c 56 $result = $this->callAPIAndDocument('MailSettings', 'create', $this->params, __FUNCTION__, __FILE__);
6a488035
TO
57 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
58 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
59 }
60
61 public function testGetMailSettings() {
62
50debe3c 63 $result = $this->callAPIAndDocument('MailSettings', 'get', $this->params, __FUNCTION__, __FILE__);
6a488035
TO
64 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
65 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
6a488035
TO
66 }
67
68 public function testDeleteMailSettings() {
50debe3c 69 $entity = $this->callAPISuccess('MailSettings', 'get', $this->params);
6a488035
TO
70 $this->assertEquals('setting.com', $entity['values'][$entity['id']]['domain'], 'In line ' . __LINE__);
71
50debe3c 72 $result = $this->callAPIAndDocument('MailSettings', 'delete', array('id' => $entity['id']), __FUNCTION__, __FILE__);
73 $checkDeleted = $this->callAPISuccess('MailSettings', 'get', array());
6a488035
TO
74 $this->assertEquals('EXAMPLE.ORG', $checkDeleted['values'][$checkDeleted['id']]['domain'], 'In line ' . __LINE__);
75 }
76
77 public function testGetMailSettingsChainDelete() {
78 $description = "demonstrates get + delete in the same call";
79 $subfile = 'ChainedGetDelete';
80 $params = array(
6a488035
TO
81 'title' => "MailSettings title",
82 'api.MailSettings.delete' => 1,
83 );
50debe3c 84 $result = $this->callAPISuccess('MailSettings', 'create', $this->params);
85 $result = $this->callAPIAndDocument('MailSettings', 'get', $params, __FUNCTION__, __FILE__, $description, $subfile);
86 $this->assertEquals(0, $this->callAPISuccess('MailSettings', 'getcount', array()), 'In line ' . __LINE__);
6a488035
TO
87 }
88}
89