You are here

public function ProfileCustomerTest::testCustomerProfile in Commerce Migrate 8.2

Same name and namespace in other branches
  1. 3.1.x modules/magento/tests/src/Kernel/Migrate/magento2/ProfileCustomerTest.php \Drupal\Tests\commerce_migrate_magento\Kernel\Migrate\magento2\ProfileCustomerTest::testCustomerProfile()
  2. 3.0.x modules/magento/tests/src/Kernel/Migrate/magento2/ProfileCustomerTest.php \Drupal\Tests\commerce_migrate_magento\Kernel\Migrate\magento2\ProfileCustomerTest::testCustomerProfile()

Test profile migration.

File

modules/magento/tests/src/Kernel/Migrate/magento2/ProfileCustomerTest.php, line 121

Class

ProfileCustomerTest
Tests billing profile migration.

Namespace

Drupal\Tests\commerce_migrate_magento\Kernel\Migrate\magento2

Code

public function testCustomerProfile() {
  $this
    ->assertProfile(1, 'customer', '1', 'und', TRUE, TRUE, NULL, NULL);
  $profile = Profile::load(1);
  $address = $profile
    ->get('address')
    ->first()
    ->getValue();
  $this
    ->assertAddressField($address, 'US', 'Michigan', 'Calder', NULL, '49628-7978', NULL, '6146 Honey Bluff Parkway', 'Apartment 242', 'Veronica', NULL, 'Costello', '');
  $phone = [
    [
      'value' => '(555) 229-3326',
    ],
  ];
  $this
    ->assertSame($phone, $profile
    ->get('phone')
    ->getValue());
  $this
    ->assertProfile(2, 'customer', '2', 'und', TRUE, FALSE, NULL, NULL);
  $profile = Profile::load(2);
  $address = $profile
    ->get('address')
    ->first()
    ->getValue();
  $this
    ->assertAddressField($address, 'US', 'Maryland', 'Towson', NULL, '21210', NULL, '333 Moa Walk', NULL, 'Tui', NULL, 'Song', '');
  $phone = [
    [
      'value' => '333-4444',
    ],
  ];
  $this
    ->assertSame($phone, $profile
    ->get('phone')
    ->getValue());

  // Test revisions.
  $this
    ->assertProfileRevision(2, 'customer', '2', 'und', TRUE, TRUE, NULL, NULL);

  /** @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', 'Maryland', 'Towson', NULL, '21210', NULL, '500 Falcon Street', NULL, 'Tui', NULL, 'Song', '');
  $this
    ->assertProfileRevision(3, 'customer', '2', 'und', TRUE, FALSE, NULL, NULL);
  $profile_revision = \Drupal::entityTypeManager()
    ->getStorage('profile')
    ->loadRevision(3);
  $address = $profile_revision
    ->get('address')
    ->first()
    ->getValue();
  $this
    ->assertAddressField($address, 'US', 'Maryland', 'Towson', NULL, '21210', NULL, '333 Moa Walk', NULL, 'Tui', NULL, 'Song', '');
}