You are here

public function AgreementMigrateTest::testDataMigration in Agreement 8.2

Same name in this branch
  1. 8.2 tests/src/Kernel/d6/AgreementMigrateTest.php \Drupal\Tests\agreement\Kernel\d6\AgreementMigrateTest::testDataMigration()
  2. 8.2 tests/src/Kernel/d7/AgreementMigrateTest.php \Drupal\Tests\agreement\Kernel\d7\AgreementMigrateTest::testDataMigration()
Same name and namespace in other branches
  1. 3.0.x tests/src/Kernel/d6/AgreementMigrateTest.php \Drupal\Tests\agreement\Kernel\d6\AgreementMigrateTest::testDataMigration()

Asserts that agreement types and agreements migrated.

File

tests/src/Kernel/d6/AgreementMigrateTest.php, line 46

Class

AgreementMigrateTest
Tests agreement migration from 6.x-2.x.

Namespace

Drupal\Tests\agreement\Kernel\d6

Code

public function testDataMigration() {
  $agreementHandler = $this->container
    ->get('agreement.handler');
  $entityTypeManager = $this->container
    ->get('entity_type.manager');

  /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $configStorage */
  $configStorage = $entityTypeManager
    ->getStorage('agreement');
  $agreement_types = $configStorage
    ->loadMultiple();
  $this
    ->assertEquals(1, count($agreement_types), 'Found default agreement type.');

  /** @var \Drupal\agreement\Entity\Agreement $default */
  $default = $configStorage
    ->load('default');
  $user2 = User::load(2);
  $user8 = User::load(8);
  $this
    ->assertGreaterThan(-1, $agreementHandler
    ->lastAgreed($default, $user2), 'john.doe agreed to default agreement.');
  $this
    ->assertEquals(-1, $agreementHandler
    ->lastAgreed($default, $user8), 'john.roe did not agree to default agreement.');
}