You are here

public function MigrateUpgradeAddToCartTest::testMigrateUpgrade in Commerce Migrate 8.2

Same name in this branch
  1. 8.2 modules/ubercart/tests/src/Functional/uc6/MigrateUpgradeAddToCartTest.php \Drupal\Tests\commerce_migrate_ubercart\Functional\uc6\MigrateUpgradeAddToCartTest::testMigrateUpgrade()
  2. 8.2 modules/commerce/tests/src/Functional/commerce1/MigrateUpgradeAddToCartTest.php \Drupal\Tests\commerce_migrate_commerce\Functional\commerce1\MigrateUpgradeAddToCartTest::testMigrateUpgrade()
Same name and namespace in other branches
  1. 3.1.x modules/commerce/tests/src/Functional/commerce1/MigrateUpgradeAddToCartTest.php \Drupal\Tests\commerce_migrate_commerce\Functional\commerce1\MigrateUpgradeAddToCartTest::testMigrateUpgrade()
  2. 3.0.x modules/commerce/tests/src/Functional/commerce1/MigrateUpgradeAddToCartTest.php \Drupal\Tests\commerce_migrate_commerce\Functional\commerce1\MigrateUpgradeAddToCartTest::testMigrateUpgrade()

Executes all steps of migrations upgrade.

File

modules/commerce/tests/src/Functional/commerce1/MigrateUpgradeAddToCartTest.php, line 89

Class

MigrateUpgradeAddToCartTest
Tests adding a product to the cart after a full migration.

Namespace

Drupal\Tests\commerce_migrate_commerce\Functional\commerce1

Code

public function testMigrateUpgrade() {
  $connection_options = $this->sourceDatabase
    ->getConnectionOptions();
  $session = $this
    ->assertSession();
  $driver = $connection_options['driver'];
  $connection_options['prefix'] = $connection_options['prefix']['default'];

  // Use the driver connection form to get the correct options out of the
  // database settings. This supports all of the databases we test against.
  $drivers = drupal_get_database_types();
  $form = $drivers[$driver]
    ->getFormOptions($connection_options);
  $connection_options = array_intersect_key($connection_options, $form + $form['advanced_options']);
  $version = $this
    ->getLegacyDrupalVersion($this->sourceDatabase);
  $edit = [
    $driver => $connection_options,
    'source_private_file_path' => $this
      ->getSourceBasePath(),
    'version' => $version,
  ];
  if ($version == 6) {
    $edit['d6_source_base_path'] = $this
      ->getSourceBasePath();
  }
  else {
    $edit['source_base_path'] = $this
      ->getSourceBasePath();
  }
  if (count($drivers) !== 1) {
    $edit['driver'] = $driver;
  }
  $edits = $this
    ->translatePostValues($edit);

  // Start the upgrade process.
  $this
    ->drupalGet('/upgrade');
  $this
    ->drupalPostForm(NULL, [], t('Continue'));
  $session
    ->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
  $session
    ->fieldExists('mysql[host]');
  $this
    ->drupalPostForm(NULL, $edits, t('Review upgrade'));
  $session
    ->statusCodeEquals(200);
  $this
    ->drupalPostForm(NULL, [], t('Perform upgrade'));

  // Add to cart.
  \Drupal::service('commerce_cart.cart_provider')
    ->createCart('default');
  $this
    ->drupalGet('/product/15');
  $this
    ->drupalPostForm(NULL, [], t('Add to cart'));
  $session
    ->pageTextContains('Tote Bag 1 added to your cart.');
}