3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviUnitTestCase.php';
32 * Test APIv3 civicrm_website_* functions
34 * @package CiviCRM_APIv3
35 * @subpackage API_Contact
38 class api_v3_WebsiteTest
extends CiviUnitTestCase
{
39 protected $_apiversion;
43 public $_eNoticeCompliant = TRUE;
44 public $DBResetRequired = FALSE;
49 $this->_entity
= 'website';
50 $this->_apiversion
= 3;
51 $this->_contactID
= $this->organizationCreate();
52 $this->params
= array(
54 'contact_id' => $this->_contactID
,
55 'url' => 'website.com',
56 'website_type_id' => 1,
61 $this->quickCleanup(array(
67 public function testCreateWebsite() {
68 $result = civicrm_api($this->_entity
, 'create', $this->params
);
69 $this->documentMe($this->params
, $result, __FUNCTION__
, __FILE__
);
70 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
71 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
72 $this->getAndCheck($this->params
, $result['id'], $this->_entity
);
73 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__
);
76 public function testGetWebsite() {
77 $result = civicrm_api($this->_entity
, 'create', $this->params
);
78 $result = civicrm_api($this->_entity
, 'get', $this->params
);
79 $this->documentMe($this->params
, $result, __FUNCTION__
, __FILE__
);
80 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
81 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
82 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__
);
83 civicrm_api('website', 'delete', array('version' => 3, 'id' => $result['id']));
86 public function testDeleteWebsite() {
87 $result = civicrm_api($this->_entity
, 'create', $this->params
);
88 $this->assertAPISuccess($result, 'in line ' . __LINE__
);
89 $deleteParams = array('version' => 3, 'id' => $result['id']);
90 $result = civicrm_api($this->_entity
, 'delete', $deleteParams);
91 $this->documentMe($deleteParams, $result, __FUNCTION__
, __FILE__
);
92 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
93 $checkDeleted = civicrm_api($this->_entity
, 'get', array(
96 $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__
);
98 public function testDeleteWebsiteInvalid() {
99 $result = civicrm_api($this->_entity
, 'create', $this->params
);
100 $this->assertAPISuccess($result, 'in line ' . __LINE__
);
101 $deleteParams = array('version' => 3, 'id' => 600);
102 $result = civicrm_api($this->_entity
, 'delete', $deleteParams);
103 $this->assertEquals(1,$result['is_error'], 'In line ' . __LINE__
);
104 $checkDeleted = civicrm_api($this->_entity
, 'get', array(
107 $this->assertEquals(1, $checkDeleted['count'], 'In line ' . __LINE__
);