useTransaction(TRUE); } public function testCreateLocBlock() { $email = $this->callAPISuccess('email', 'create', array( 'contact_id' => 'null', 'location_type_id' => 1, 'email' => 'test@loc.block', )); $phone = $this->callAPISuccess('phone', 'create', array( 'contact_id' => 'null', 'location_type_id' => 1, 'phone' => '1234567', )); $address = $this->callAPISuccess('address', 'create', array( 'contact_id' => 'null', 'location_type_id' => 1, 'street_address' => '1234567', )); $params = array( 'address_id' => $address['id'], 'phone_id' => $phone['id'], 'email_id' => $email['id'], ); $description = 'Create locBlock with existing entities'; $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'simpleCreate'); $id = $result['id']; $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertNotNull($result['values'][$id]['id'], 'In line ' . __LINE__); $this->getAndCheck($params, $id, $this->_entity); } public function testCreateLocBlockEntities() { $params = array( 'email' => array( 'location_type_id' => 1, 'email' => 'test2@loc.block', ), 'phone' => array( 'location_type_id' => 1, 'phone' => '987654321', ), 'phone_2' => array( 'location_type_id' => 1, 'phone' => '456-7890', ), 'address' => array( 'location_type_id' => 1, 'street_address' => '987654321', ), ); $description = "Create entities and locBlock in 1 api call"; $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'createEntities'); $id = $result['id']; $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); // Now check our results using the return param 'all' $getParams = array( 'id' => $id, 'return' => 'all', ); // Can't use callAPISuccess with getsingle $result = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__, 'Get entities and location block in 1 api call', 'getEntities', 'get'); $result = array_pop($result['values']); $this->assertNotNull($result['email_id'], 'In line ' . __LINE__); $this->assertNotNull($result['phone_id'], 'In line ' . __LINE__); $this->assertNotNull($result['phone_2_id'], 'In line ' . __LINE__); $this->assertNotNull($result['address_id'], 'In line ' . __LINE__); $this->assertEquals($params['email']['email'], $result['email']['email'], 'In line ' . __LINE__); $this->assertEquals($params['phone_2']['phone'], $result['phone_2']['phone'], 'In line ' . __LINE__); $this->assertEquals($params['address']['street_address'], $result['address']['street_address'], 'In line ' . __LINE__); // Delete block $result = $this->callAPISuccess($this->_entity, 'delete', array('id' => $id)); } }