You are here

public function ProfileBillingDeletedUserTest::testProfileBilling in Commerce Migrate 3.1.x

Same name in this branch
  1. 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc7/ProfileBillingDeletedUserTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\ProfileBillingDeletedUserTest::testProfileBilling()
  2. 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc6/ProfileBillingDeletedUserTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\ProfileBillingDeletedUserTest::testProfileBilling()
Same name and namespace in other branches
  1. 8.2 modules/ubercart/tests/src/Kernel/Migrate/uc7/ProfileBillingDeletedUserTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\ProfileBillingDeletedUserTest::testProfileBilling()
  2. 3.0.x modules/ubercart/tests/src/Kernel/Migrate/uc7/ProfileBillingDeletedUserTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\ProfileBillingDeletedUserTest::testProfileBilling()

Test profile migration.

File

modules/ubercart/tests/src/Kernel/Migrate/uc7/ProfileBillingDeletedUserTest.php, line 68

Class

ProfileBillingDeletedUserTest
Tests customer profile migration.

Namespace

Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7

Code

public function testProfileBilling() {

  // Profile for order_id 1.
  $profile_id = 1;
  $this
    ->assertProfile($profile_id, 'customer', '2', 'und', TRUE, TRUE, '1536902338', NULL);
  $profile = Profile::load($profile_id);
  $address = $profile
    ->get('address')
    ->first()
    ->getValue();
  $this
    ->assertAddressField($address, 'CA', NULL, 'Starship Voyager', NULL, '', NULL, 'Level 12', '', 'Tom', NULL, 'Paris', '');
  $phone = $profile
    ->get('phone')
    ->getValue();
  $this
    ->assertSame([], $phone);

  // Profile for order_id 2.
  $profile_id = 2;
  $this
    ->assertProfile($profile_id, 'customer', '0', 'und', FALSE, FALSE, '1536902428', NULL);
  $profile = Profile::load($profile_id);
  $address = $profile
    ->get('address')
    ->first()
    ->getValue();
  $this
    ->assertAddressField($address, 'CA', NULL, '', NULL, '', NULL, '', '', '', NULL, '', '');
  $phone = $profile
    ->get('phone')
    ->getValue();
  $this
    ->assertSame([], $phone);

  // Tests the first revision of order 1.

  /** @var \Drupal\profile\Entity\ProfileInterface $profile_revision */
  $profile_revision = \Drupal::entityTypeManager()
    ->getStorage('profile')
    ->loadRevision(1);
  $address = $profile_revision
    ->get('address')
    ->first()
    ->getValue();
  $this
    ->assertAddressField($address, 'US', 'AL', 'San Francisco', NULL, '74656', NULL, '', '', 'Tom', NULL, 'Paris', '');
  $phone = $profile_revision
    ->get('phone')
    ->getValue()[0]['value'];
  $this
    ->assertSame('555-4747', $phone);

  // Tests the first revision of order 2.

  /** @var \Drupal\profile\Entity\ProfileInterface $profile_revision */
  $profile_revision = \Drupal::entityTypeManager()
    ->getStorage('profile')
    ->loadRevision(2);
  $address = $profile_revision
    ->get('address')
    ->first()
    ->getValue();
  $this
    ->assertAddressField($address, 'US', 'CA', 'San Francisco', NULL, '', NULL, '33 First Street', '', 'Harry', NULL, 'Kim', '');
  $phone = $profile
    ->get('phone')
    ->getValue();
  $this
    ->assertSame([], $phone);
}