public function CrmCoreUserSyncRelationTest::testRulesRespected 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::testRulesRespected()
Tests that configured rules are respected when related contacts created.
File
- modules/
crm_core_user_sync/ tests/ src/ Kernel/ CrmCoreUserSyncRelationTest.php, line 112
Class
- CrmCoreUserSyncRelationTest
- Test description.
Namespace
Drupal\Tests\crm_core_user_sync\KernelCode
public function testRulesRespected() {
$account_authenticated = User::create([
'name' => 'authenticated',
'uid' => rand(50, 100),
]);
$account_authenticated
->save();
$contact_individual_id = $this->relationService
->getIndividualIdFromUserId($account_authenticated
->id());
$this
->assertNotEmpty($contact_individual_id, 'Individual contact was created when authenticated user account was created.');
$contact_individual = Individual::load($contact_individual_id);
$this
->assertEquals('individual', $contact_individual
->bundle(), 'Individual contact has correct bundle');
$customer_values = [
'name' => 'customer',
'roles' => [
'customer',
],
];
$account_customer = User::create($customer_values);
$account_customer
->save();
$contact_customer_id = $this->relationService
->getIndividualIdFromUserId($account_customer
->id());
$this
->assertNotEmpty($contact_customer_id, 'Individual contact was created when customer user account was created.');
$contact_customer = Individual::load($contact_customer_id);
$this
->assertEquals('customer', $contact_customer
->bundle(), 'Individual contact has correct bundle');
}