useTransaction(); $this->_entity = 'website'; $this->_contactID = $this->organizationCreate(); $this->params = array( 'contact_id' => $this->_contactID, 'url' => 'website.com', 'website_type_id' => 1, ); } public function testCreateWebsite() { $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params, __FUNCTION__, __FILE__); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->getAndCheck($this->params, $result['id'], $this->_entity); $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__); } public function testGetWebsite() { $result = $this->callAPISuccess($this->_entity, 'create', $this->params); $result = $this->callAPIAndDocument($this->_entity, 'get', $this->params, __FUNCTION__, __FILE__); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__); $this->callAPISuccess('website', 'delete', array('id' => $result['id'])); } public function testDeleteWebsite() { $result = $this->callAPISuccess($this->_entity, 'create', $this->params); $deleteParams = array('id' => $result['id']); $result = $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__); $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array()); $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__); } public function testDeleteWebsiteInvalid() { $result = $this->callAPISuccess($this->_entity, 'create', $this->params); $deleteParams = array('id' => 600); $result = $this->callAPIFailure($this->_entity, 'delete', $deleteParams); $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array()); $this->assertEquals(1, $checkDeleted['count'], 'In line ' . __LINE__); } /** * Test retrieval of metadata */ public function testGetMetadata() { $result = $this->callAPIAndDocument($this->_entity, 'get', array( 'options' => array( 'metadata' => array('fields'), ) ), __FUNCTION__, __FILE__, 'Demonostrates returning field metadata', 'GetWithMetadata'); $this->assertEquals('Website', $result['metadata']['fields']['url']['title']); } /** * Test retrieval of label metadata */ public function testGetFields() { $result = $this->callAPIAndDocument($this->_entity, 'getfields', array('action' => 'get'), __FUNCTION__, __FILE__); $this->assertArrayKeyExists('url', $result['values']); } }