コード例 #1
0
ファイル: OpenIDTest.php プロジェクト: sdekok/civicrm-core
 /**
  * AllOpenIDs() method - get all OpenIDs for the given contact
  */
 public function testAllOpenIDs()
 {
     $contactId = Contact::createIndividual();
     $this->assertDBRowExist('CRM_Contact_DAO_Contact', $contactId);
     // create first openid
     $openIdURLOne = "http://test-one-username.civicrm.org/";
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'openid' => $openIdURLOne, 'is_primary' => 1, 'allowed_to_login' => 1);
     $openObjectOne = CRM_Core_BAO_OpenID::add($params);
     $openIdOne = $openObjectOne->id;
     $this->assertDBNotNull('CRM_Core_DAO_OpenID', $openIdURLOne, 'id', 'openid', 'Database check for created OpenID.');
     // create second openid
     $openIdURLTwo = "http://test-two-username.civicrm.org/";
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'openid' => $openIdURLTwo);
     $openObjectTwo = CRM_Core_BAO_OpenID::add($params);
     $openIdTwo = $openObjectTwo->id;
     $this->assertDBNotNull('CRM_Core_DAO_OpenID', $openIdURLTwo, 'id', 'openid', 'Database check for created OpenID.');
     // obtain all openids for the contact
     $openIds = CRM_Core_BAO_OpenID::allOpenIDs($contactId);
     // check number of openids for the contact
     $this->assertEquals(2, count($openIds), 'Checking number of returned open-ids.');
     // check first openid values
     $this->assertEquals($openIdURLOne, $openIds[$openIdOne]['openid'], 'Confirm first openid value.');
     $this->assertEquals(1, $openIds[$openIdOne]['is_primary'], 'Confirm is_primary field value.');
     $this->assertEquals(1, $openIds[$openIdOne]['allowed_to_login'], 'Confirm allowed_to_login field value.');
     // check second openid values
     $this->assertEquals($openIdURLTwo, $openIds[$openIdTwo]['openid'], 'Confirm second openid value.');
     $this->assertEquals(0, $openIds[$openIdTwo]['is_primary'], 'Confirm is_primary field value for second openid.');
     $this->assertEquals(0, $openIds[$openIdTwo]['allowed_to_login'], 'Confirm allowed_to_login field value for second openid.');
     //Contact::delete($contactId);
     $this->contactDelete($contactId);
     $this->assertDBRowNotExist('CRM_Contact_DAO_Contact', $contactId);
 }
コード例 #2
0
ファイル: OpenIDTest.php プロジェクト: ksecor/civicrm
 /**
  * allOpenIDs() method - get all OpenIDs for the given contact
  */
 function testAllOpenIDs()
 {
     $contactId = Contact::createIndividual();
     // create first openid
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'endpoint_url' => $openid['endpoint_url'], 'claimed_id' => $openid['claimed_id'], 'display_id' => $openid['display_id'], 'is_primary' => 1, 'allowed_to_login' => 1);
     require_once 'CRM/Core/BAO/OpenID.php';
     $openObjectOne = CRM_Core_BAO_OpenID::add($params);
     $openIdOne_id = $openObjectOne->id;
     $this->assertDBCompareValues('CRM_Core_DAO_OpenID', array('id' => $openIdOne_id), $openid);
     // create second openid
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'endpoint_url' => $openid_two['endpoint_url'], 'claimed_id' => $openid_two['claimed_id'], 'display_id' => $openid_two['display_id']);
     $openObjectTwo = CRM_Core_BAO_OpenID::add($params);
     $openIdTwo_id = $openObjectTwo->id;
     $this->assertDBCompareValues('CRM_Core_DAO_OpenID', array('id' => $openIdTwo_id), $openid_two);
     // obtain all openids for the contact
     $openIds = CRM_Core_BAO_OpenID::allOpenIDs($contactId);
     // check number of openids for the contact
     $this->assertEquals(count($openIds), 2, 'Checking number of returned OpenIDs.');
     // check first openid values
     $this->assertAttributesEquals($openid, $openIds[$openIdOne_id]);
     $this->assertEquals(1, $openIds[$openIdOne_id]['is_primary'], 'Confirm is_primary field value.');
     $this->assertEquals(1, $openIds[$openIdOne_id]['allowed_to_login'], 'Confirm allowed_to_login field value.');
     // check second openid values
     $this->assertAttributesEquals($openid_two, $openIds[$openIdTwo_id]);
     $this->assertEquals(0, $openIds[$openIdTwo_id]['is_primary'], 'Confirm is_primary field value for second openid.');
     $this->assertEquals(0, $openIds[$openIdTwo_id]['allowed_to_login'], 'Confirm allowed_to_login field value for second openid.');
     Contact::delete($contactId);
 }