You are here

public function RelationEntityTest::testRelationMethods in CRM Core 8.3

Same name and namespace in other branches
  1. 8 modules/crm_core_user_sync/tests/src/Kernel/RelationEntityTest.php \Drupal\Tests\crm_core_user_sync\Kernel\RelationEntityTest::testRelationMethods()

Tests some of the methods.

See also

\Drupal\crm_core_user_sync\Entity\Relation::setUserId()

\Drupal\crm_core_user_sync\Entity\Relation::setIndividualId()

\Drupal\crm_core_user_sync\Entity\Relation::getUserId()

\Drupal\crm_core_user_sync\Entity\Relation::getIndividualId()

File

modules/crm_core_user_sync/tests/src/Kernel/RelationEntityTest.php, line 42

Class

RelationEntityTest
Tests the relation entity class.

Namespace

Drupal\Tests\crm_core_user_sync\Kernel

Code

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');
}