RelationEntityTest.php in CRM Core 8
File
modules/crm_core_user_sync/tests/src/Kernel/RelationEntityTest.php
View source
<?php
namespace Drupal\Tests\crm_core_user_sync\Kernel;
use Drupal\crm_core_user_sync\Entity\Relation;
use Drupal\KernelTests\KernelTestBase;
class RelationEntityTest extends KernelTestBase {
public static $modules = [
'system',
'user',
'name',
'crm_core_contact',
'crm_core_user_sync',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('crm_core_user_sync_relation');
}
public function testRelationMethods() {
$user_id_1 = 1;
$individual_id_1 = 1;
$user_id_2 = 2;
$individual_id_2 = 2;
$relation = Relation::create([
'user_id' => $user_id_1,
'individual_id' => $individual_id_1,
]);
$this
->assertEquals($user_id_1, $relation
->getUserId(), 'User ID match');
$this
->assertEquals($individual_id_1, $relation
->getIndividualId(), 'Individual ID match');
$relation
->setUserId($user_id_2);
$this
->assertEquals($user_id_2, $relation
->getUserId(), 'User ID match');
$relation
->setIndividualId($individual_id_2);
$this
->assertEquals($individual_id_2, $relation
->getIndividualId(), 'Individual ID match');
}
}