diff --git a/modules/ubercart/migration_templates/d6_ubercart_tax.yml b/modules/ubercart/migration_templates/d6_ubercart_tax.yml deleted file mode 100644 index 95cf3a0..0000000 --- a/modules/ubercart/migration_templates/d6_ubercart_tax.yml +++ /dev/null @@ -1,28 +0,0 @@ -# Ubercart currency information. -id: d6_ubercart_tax -label: Migrate taxes from Ubercart -migration_group: ubercart -migration_tags: - - Drupal 6 - - Drupal 6 Ubercart -source: - plugin: d6_ubercart_tax - constants: - plugin: 'custom' -process: - id: - - - plugin: machine_name - source: name - - - plugin: make_unique_entity_field - entity_type: commerce_tax_type - field: id - length: 32 - label: name - 'plugin': 'constants/plugin' - 'configuration/rates/0/id': '@id' - 'configuration/rates/0/label': name - 'configuration/rates/0/amount': rate -destination: - plugin: entity:commerce_tax_type diff --git a/modules/ubercart/migration_templates/d6_ubercart_tax_type.yml b/modules/ubercart/migration_templates/d6_ubercart_tax_type.yml new file mode 100644 index 0000000..abf3bb3 --- /dev/null +++ b/modules/ubercart/migration_templates/d6_ubercart_tax_type.yml @@ -0,0 +1,27 @@ +# Ubercart 6 taxes. +id: d6_ubercart_tax_type +label: Migrate taxes from Ubercart +migration_tags: + - Drupal 6 + - Ubercart +source: + plugin: d6_ubercart_tax_type + constants: + plugin: 'custom' +process: + id: + - + plugin: machine_name + source: name + - + plugin: make_unique_entity_field + entity_type: commerce_tax_type + field: id + length: 32 + label: name + 'plugin': 'constants/plugin' + 'configuration/rates/0/id': '@id' + 'configuration/rates/0/label': name + 'configuration/rates/0/amount': rate +destination: + plugin: entity:commerce_tax_type diff --git a/modules/ubercart/src/Plugin/migrate/source/Tax.php b/modules/ubercart/src/Plugin/migrate/source/Tax.php deleted file mode 100644 index f0c0a61..0000000 --- a/modules/ubercart/src/Plugin/migrate/source/Tax.php +++ /dev/null @@ -1,51 +0,0 @@ -select('uc_taxes', 'ut') - ->fields('ut', array_keys($this->fields())); - - return $query; - } - - /** - * {@inheritdoc} - */ - public function fields() { - $fields = [ - 'id' => $this->t('Tax ID'), - 'name' => $this->t('Tax Name'), - 'rate' => $this->t('Tax Rate'), - ]; - - return $fields; - } - - /** - * {@inheritdoc} - */ - public function getIds() { - return [ - 'id' => [ - 'type' => 'integer', - 'alias' => 'ut', - ], - ]; - } - -} diff --git a/modules/ubercart/src/Plugin/migrate/source/TaxType.php b/modules/ubercart/src/Plugin/migrate/source/TaxType.php new file mode 100644 index 0000000..827cedd --- /dev/null +++ b/modules/ubercart/src/Plugin/migrate/source/TaxType.php @@ -0,0 +1,51 @@ +select('uc_taxes', 'ut') + ->fields('ut', array_keys($this->fields())); + + return $query; + } + + /** + * {@inheritdoc} + */ + public function fields() { + $fields = [ + 'id' => $this->t('TaxType ID'), + 'name' => $this->t('TaxType Name'), + 'rate' => $this->t('TaxType Rate'), + ]; + + return $fields; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + return [ + 'id' => [ + 'type' => 'integer', + 'alias' => 'ut', + ], + ]; + } + +} diff --git a/modules/ubercart/tests/src/Kernel/Migrate/d6/TaxTest.php b/modules/ubercart/tests/src/Kernel/Migrate/d6/TaxTest.php deleted file mode 100644 index 4f92226..0000000 --- a/modules/ubercart/tests/src/Kernel/Migrate/d6/TaxTest.php +++ /dev/null @@ -1,40 +0,0 @@ -installEntitySchema('commerce_tax_type'); - $this->executeMigration('d6_ubercart_tax'); - } - - /** - * Test tax migration from Drupal 6 to 8. - */ - public function testTaxType() { - $this->assertTaxType('handling', 'Handling', 'custom', '0.04'); - } - -} diff --git a/modules/ubercart/tests/src/Kernel/Migrate/d6/TaxTypeTest.php b/modules/ubercart/tests/src/Kernel/Migrate/d6/TaxTypeTest.php new file mode 100644 index 0000000..c15a773 --- /dev/null +++ b/modules/ubercart/tests/src/Kernel/Migrate/d6/TaxTypeTest.php @@ -0,0 +1,39 @@ +installEntitySchema('commerce_tax_type'); + $this->executeMigration('d6_ubercart_tax_type'); + } + + /** + * Test tax migration from Drupal 6 to 8. + */ + public function testTaxType() { + $this->assertTaxType('handling', 'Handling', 'custom', '0.04'); + } + +} diff --git a/tests/src/Kernel/CommerceMigrateTestTrait.php b/tests/src/Kernel/CommerceMigrateTestTrait.php index 7ad72e7..94bfcf3 100644 --- a/tests/src/Kernel/CommerceMigrateTestTrait.php +++ b/tests/src/Kernel/CommerceMigrateTestTrait.php @@ -320,24 +320,24 @@ trait CommerceMigrateTestTrait { * * @param int $id * The TaxType id. - * @param string $expected_label + * @param string $label * The label for the TaxType. - * @param string $expected_plugin + * @param string $plugin * The TaxType plugin. * @param string $rate * The TaxType rate. */ - public function assertTaxType($id, $expected_label, $expected_plugin, $rate) { - $tax = TaxType::load($id); - $this->assertNotNull($tax); - $this->assertInstanceOf(TaxType::class, $tax); - $this->assertSame($expected_label, $tax->label()); - $this->assertSame($expected_plugin, $tax->getPluginId()); + public function assertTaxType($id, $label, $plugin, $rate) { + $tax_type = TaxType::load($id); + $this->assertNotNull($tax_type); + $this->assertInstanceOf(TaxType::class, $tax_type); + $this->assertSame($label, $tax_type->label()); + $this->assertSame($plugin, $tax_type->getPluginId()); - $tax_config = $tax->getPluginConfiguration(); - $this->assertSame($id, $tax_config['rates'][0]['id']); - $this->assertSame($expected_label, $tax_config['rates'][0]['label']); - $this->assertSame($rate, $tax_config['rates'][0]['amount']); + $tax_type_config = $tax_type->getPluginConfiguration(); + $this->assertSame($id, $tax_type_config['rates'][0]['id']); + $this->assertSame($label, $tax_type_config['rates'][0]['label']); + $this->assertSame($rate, $tax_type_config['rates'][0]['amount']); } }