You are here

public function MigratePhoneNumberTestTrait::testPhoneNumberMigration in SMS Framework 8

Same name and namespace in other branches
  1. 2.x tests/src/Kernel/Migrate/MigratePhoneNumberTestTrait.php \Drupal\Tests\sms\Kernel\Migrate\MigratePhoneNumberTestTrait::testPhoneNumberMigration()
  2. 2.1.x tests/src/Kernel/Migrate/MigratePhoneNumberTestTrait.php \Drupal\Tests\sms\Kernel\Migrate\MigratePhoneNumberTestTrait::testPhoneNumberMigration()

Tests that the users' phone numbers verification status is migrated.

File

tests/src/Kernel/Migrate/MigratePhoneNumberTestTrait.php, line 78

Class

MigratePhoneNumberTestTrait
This trait executes tests for D6 and D7 SMS Framework migrations.

Namespace

Drupal\Tests\sms\Kernel\Migrate

Code

public function testPhoneNumberMigration() {
  $this
    ->loadFixture($this
    ->smsUserFixtureFilePath());

  // Set up phone number verifications.
  $this
    ->installEntitySchema('sms');
  $this
    ->installEntitySchema('sms_phone_number_verification');
  $this
    ->executeMigrations($this
    ->getMigrationsToTest());
  $user = User::load(40);
  $this
    ->assertEquals('1234567890', $user
    ->get('phone_number')->value);
  $this
    ->assertVerifiedPhoneNumber($user, '1234567890');
  $user = User::load(41);
  $this
    ->assertEquals('87654321190', $user
    ->get('phone_number')->value);
  $this
    ->assertUnVerifiedPhoneNumber($user, '87654321190');
  $this
    ->assertVerificationCode('87654321190', '8002');

  // No phone number for user 15.
  $user = User::load(42);
  $this
    ->assertEquals('', $user
    ->get('phone_number')->value);
  $this
    ->assertNoVerifiedPhoneNumber($user);
}