View source  
  <?php
namespace Drupal\Tests\commerce_migrate_ubercart\Functional\uc6;
use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeTestBase;
class MigrateUpgradeAddToCartTest extends MigrateUpgradeTestBase {
  
  public static $modules = [
    'address',
    'block',
    'block_content',
    'comment',
    'commerce',
    'commerce_cart',
    'commerce_log',
    'commerce_migrate',
    'commerce_migrate_ubercart',
    'commerce_number_pattern',
    'commerce_order',
    'commerce_payment',
    'commerce_price',
    'commerce_product',
    'commerce_promotion',
    'commerce_shipping',
    'commerce_store',
    'datetime',
    'dblog',
    'entity',
    'entity_reference_revisions',
    'field',
    'file',
    'filter',
    'image',
    'inline_entity_form',
    'link',
    'migrate',
    'migrate_drupal',
    'migrate_drupal_ui',
    'migrate_plus',
    'node',
    'options',
    'path',
    'path_alias',
    'profile',
    'search',
    'shortcut',
    'state_machine',
    'system',
    'taxonomy',
    'telephone',
    'text',
    'user',
    'views',
  ];
  
  protected function setUp() {
    parent::setUp();
    $this
      ->writeSettings([
      'settings' => [
        'migrate_node_migrate_type_classic' => (object) [
          'value' => TRUE,
          'required' => TRUE,
        ],
      ],
    ]);
    $this
      ->loadFixture(drupal_get_path('module', 'commerce_migrate_ubercart') . '/tests/fixtures/uc6.php');
  }
  
  public function testMigrateUpgrade() {
    $connection_options = $this->sourceDatabase
      ->getConnectionOptions();
    $session = $this
      ->assertSession();
    $driver = $connection_options['driver'];
    $connection_options['prefix'] = $connection_options['prefix']['default'];
    
    $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);
    
    $this
      ->drupalGet('/upgrade');
    $this
      ->drupalPostForm(NULL, [], 'Continue');
    $session
      ->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
    $session
      ->fieldExists('mysql[host]');
    $this
      ->drupalPostForm(NULL, $edits, 'Review upgrade');
    $session
      ->statusCodeEquals(200);
    $this
      ->drupalPostForm(NULL, [], 'Perform upgrade');
    
    drupal_flush_all_caches();
    
    \Drupal::service('commerce_cart.cart_provider')
      ->createCart('default');
    $this
      ->drupalGet('/product/2');
    $this
      ->drupalPostForm(NULL, [], 'Add to cart');
    $session
      ->pageTextContains('Beach Towel added to your cart.');
  }
  
  protected function getSourceBasePath() {
    return '';
  }
  
  protected function getEntityCounts() {
    return [];
  }
  
  protected function getEntityCountsIncremental() {
  }
  
  protected function getAvailablePaths() {
    return [];
  }
  
  protected function getMissingPaths() {
    return [];
  }
}