X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fapi%2Fv3%2FLocBlockTest.php;h=b5e7b6b082182bea4ea59ceaba1b89141e42ac25;hb=a828d7b823956a46f5a3cea184389c9b108f80ac;hp=51d0b3ea9f0db7d5218aa335c7f8390711a848be;hpb=d44a51e500618f1d9abfad4cc6de65cf20226c10;p=civicrm-core.git diff --git a/tests/phpunit/api/v3/LocBlockTest.php b/tests/phpunit/api/v3/LocBlockTest.php index 51d0b3ea9f..b5e7b6b082 100644 --- a/tests/phpunit/api/v3/LocBlockTest.php +++ b/tests/phpunit/api/v3/LocBlockTest.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ require_once 'CiviTest/CiviUnitTestCase.php'; @@ -34,15 +34,20 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $_entity = 'loc_block'; + /** + * Set up. + */ public function setUp() { parent::setUp(); $this->useTransaction(TRUE); } + /** + * Test creating location block. + */ 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( @@ -61,13 +66,16 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { 'email_id' => $email['id'], ); $description = 'Create locBlock with existing entities'; - $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'simpleCreate'); + $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description); $id = $result['id']; - $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); - $this->assertNotNull($result['values'][$id]['id'], 'In line ' . __LINE__); + $this->assertEquals(1, $result['count']); + $this->assertNotNull($result['values'][$id]['id']); $this->getAndCheck($params, $id, $this->_entity); } + /** + * Test creating location block entities. + */ public function testCreateLocBlockEntities() { $params = array( 'email' => array( @@ -87,28 +95,28 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { 'street_address' => '987654321', ), ); - $description = "Create entities and locBlock in 1 api call"; - $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'createEntities'); + $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__); + $this->assertEquals(1, $result['count']); - // Now check our results using the return param 'all' + // 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'); + // Can't use callAPISuccess with getsingle. + $result = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__, 'Get entities and location block in 1 api call'); $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)); + $this->assertNotNull($result['email_id']); + $this->assertNotNull($result['phone_id']); + $this->assertNotNull($result['phone_2_id']); + $this->assertNotNull($result['address_id']); + $this->assertEquals($params['email']['email'], $result['email']['email']); + $this->assertEquals($params['phone_2']['phone'], $result['phone_2']['phone']); + $this->assertEquals($params['address']['street_address'], $result['address']['street_address']); + + $this->callAPISuccess($this->_entity, 'delete', array('id' => $id)); } }