public function ShippingFlatRateTest::testShippingFlatRate in Commerce Migrate 3.1.x
Same name in this branch
- 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc7/ShippingFlatRateTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\ShippingFlatRateTest::testShippingFlatRate()
- 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc6/ShippingFlatRateTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\ShippingFlatRateTest::testShippingFlatRate()
- 3.1.x modules/commerce/tests/src/Kernel/Migrate/commerce1/ShippingFlatRateTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\ShippingFlatRateTest::testShippingFlatRate()
Same name and namespace in other branches
- 8.2 modules/commerce/tests/src/Kernel/Migrate/commerce1/ShippingFlatRateTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\ShippingFlatRateTest::testShippingFlatRate()
- 3.0.x modules/commerce/tests/src/Kernel/Migrate/commerce1/ShippingFlatRateTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\ShippingFlatRateTest::testShippingFlatRate()
Test flat rate shipping method migration.
File
- modules/
commerce/ tests/ src/ Kernel/ Migrate/ commerce1/ ShippingFlatRateTest.php, line 42
Class
- ShippingFlatRateTest
- Tests flat rate shipping migration from Commerce 1.
Namespace
Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1Code
public function testShippingFlatRate() {
// The Commerce 1 source does not have an id value so the methods may be in
// any order but the common assert method needs a shipping method id. So, we
// loop through each method and then set the test values accordingly. A
// counter is used to check that all 3 methods are tested.
$methods_tested_count = 0;
for ($i = 1; $i < 4; $i++) {
$shipping_method = ShippingMethod::load($i);
$name = $shipping_method
->getName();
switch ($name) {
case 'Express Shipping':
$type = [
'label' => 'Express Shipping',
'rate_amount' => [
'number' => '15.00',
'currency_code' => 'USD',
],
];
$methods_tested_count++;
break;
case 'Free Shipping':
$type = [
'label' => 'Free Shipping',
'rate_amount' => [
'number' => '0.00',
'currency_code' => 'USD',
],
];
$methods_tested_count++;
break;
case 'Standard Shipping':
$type = [
'label' => 'Standard Shipping',
'rate_amount' => [
'number' => '8.00',
'currency_code' => 'USD',
],
];
$methods_tested_count++;
break;
}
$type['id'] = $i;
$type['stores'] = [
'1',
];
$this
->assertShippingMethod($type);
}
// Check that all three methods were tested.
$this
->assertSame(3, $methods_tested_count);
}