Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
29 | ||
30 | ||
31 | /** | |
32 | * Test APIv3 civicrm_website_* functions | |
33 | * | |
34 | * @package CiviCRM_APIv3 | |
35 | * @subpackage API_Contact | |
36 | */ | |
37 | ||
38 | class api_v3_WebsiteTest extends CiviUnitTestCase { | |
39 | protected $_apiversion; | |
40 | protected $params; | |
41 | protected $id; | |
42 | protected $_entity; | |
43 | public $_eNoticeCompliant = TRUE; | |
430ae6dd TO |
44 | public $DBResetRequired = FALSE; |
45 | ||
46 | function setUp() { | |
6a488035 TO |
47 | parent::setUp(); |
48 | ||
49 | $this->_entity = 'website'; | |
50 | $this->_apiversion = 3; | |
51 | $this->_contactID = $this->organizationCreate(); | |
52 | $this->params = array( | |
53 | 'version' => 3, | |
54 | 'contact_id' => $this->_contactID, | |
55 | 'url' => 'website.com', | |
56 | 'website_type_id' => 1, | |
57 | ); | |
58 | } | |
59 | ||
60 | function tearDown() { | |
61 | $this->quickCleanup(array( | |
62 | 'civicrm_website', | |
63 | 'civicrm_contact' | |
64 | )); | |
65 | } | |
66 | ||
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__); | |
74 | } | |
75 | ||
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'])); | |
84 | } | |
85 | ||
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( | |
94 | 'version' => 3, | |
95 | )); | |
96 | $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__); | |
97 | } | |
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( | |
105 | 'version' => 3, | |
106 | )); | |
107 | $this->assertEquals(1, $checkDeleted['count'], 'In line ' . __LINE__); | |
108 | } | |
109 | } | |
110 |