SourceTestBase.php in Commerce Migrate 3.1.x
File
modules/commerce/tests/src/Kernel/Plugin/migrate/source/commerce1/SourceTestBase.php
View source
<?php
namespace Drupal\Tests\commerce_migrate_commerce\Kernel\Plugin\migrate\source\commerce1;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
abstract class SourceTestBase extends MigrateSqlSourceTestBase {
protected static $modules = [
'address',
'commerce',
'commerce_migrate_commerce',
'commerce_price',
'commerce_store',
'migrate_drupal',
'options',
'user',
];
public function setUp() : void {
parent::setUp();
$this
->installEntitySchema('user');
$this
->installEntitySchema('commerce_store');
$this
->createDefaultStore();
}
protected function createDefaultStore() {
$currency_importer = \Drupal::service('commerce_price.currency_importer');
$store_storage = \Drupal::service('entity_type.manager')
->getStorage('commerce_store');
$currency_importer
->import('USD');
$store_values = [
'type' => 'default',
'uid' => 1,
'name' => 'Demo store',
'mail' => 'admin@example.com',
'address' => [
'country_code' => 'US',
],
'default_currency' => 'USD',
];
$store = $store_storage
->create($store_values);
$store
->save();
$store_storage
->markAsDefault($store);
}
}