public function CrmCoreUserSyncRelationTest::testRelationCreated in CRM Core 8.3
Same name and namespace in other branches
- 8 modules/crm_core_user_sync/tests/src/Kernel/CrmCoreUserSyncRelationTest.php \Drupal\Tests\crm_core_user_sync\Kernel\CrmCoreUserSyncRelationTest::testRelationCreated()
Tests that relation and related individual was created.
File
- modules/
crm_core_user_sync/ tests/ src/ Kernel/ CrmCoreUserSyncRelationTest.php, line 90
Class
- CrmCoreUserSyncRelationTest
- Test description.
Namespace
Drupal\Tests\crm_core_user_sync\KernelCode
public function testRelationCreated() {
// Newly created tables for user and contact are empty so we have same IDs
// for both - 1.
$account_authenticated = User::create([
'name' => 'authenticated',
'uid' => rand(50, 100),
]);
$account_authenticated
->save();
$authenticated_relation_id = $this->relationService
->getRelationIdFromUserId($account_authenticated
->id());
$this
->assertNotEmpty($authenticated_relation_id, 'Relation was created');
$authenticated_individual_id = $this->relationService
->getIndividualIdFromUserId($account_authenticated
->id());
$this
->assertNotEmpty($authenticated_individual_id, 'Related contact was created');
$related_account_id = $this->relationService
->getUserIdFromIndividualId($authenticated_individual_id);
$this
->assertEquals($account_authenticated
->id(), $related_account_id, 'Related ');
}