class ResolveProductVariationTypeTest in Commerce Migrate 8.2
Same name and namespace in other branches
- 3.1.x modules/commerce/tests/src/Unit/Plugin/migrate/process/commerce1/ResolveProductVariationTypeTest.php \Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1\ResolveProductVariationTypeTest
- 3.0.x modules/commerce/tests/src/Unit/Plugin/migrate/process/commerce1/ResolveProductVariationTypeTest.php \Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1\ResolveProductVariationTypeTest
Tests the resolve target type process plugin.
@coversDefaultClass \Drupal\commerce_migrate_commerce\Plugin\migrate\process\commerce1\ResolveProductVariationType
@group commerce_migrate_commerce
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
- class \Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase
- class \Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1\ResolveProductVariationTypeTest
- class \Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
Expanded class hierarchy of ResolveProductVariationTypeTest
File
- modules/
commerce/ tests/ src/ Unit/ Plugin/ migrate/ process/ commerce1/ ResolveProductVariationTypeTest.php, line 16
Namespace
Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1View source
class ResolveProductVariationTypeTest extends MigrateProcessTestCase {
/**
* Tests valid values.
*
* @dataProvider providerTestTransform
*/
public function testTransform($value, $configuration, $referenceable_types, $expected) {
$row = $this
->prophesize(Row::class);
$row
->getSourceProperty('data/settings/referenceable_types')
->willReturn($referenceable_types);
$this->plugin = new ResolveProductVariationType($configuration, 'map', []);
$value = $this->plugin
->transform($value, $this->migrateExecutable, $row
->reveal(), 'foo');
$this
->assertSame($expected, $value);
}
/**
* Data provider for testTransform().
*/
public function providerTestTransform() {
return [
'count is one' => [
'bags_cases',
[],
[
'bags_cases' => 'bags_cases',
],
'bags_cases',
],
'no variations' => [
'bags_cases',
[],
[
'bags_cases' => 'bags',
'drinks' => 'drinks',
],
'bags_cases',
],
'variations no matching' => [
'bags_cases',
[
'variations' => [
'default' => 'default',
],
],
[
'bags_cases',
'drinks',
],
'default',
],
'variations with matching' => [
'drinks',
[
'variations' => [
'matching' => TRUE,
],
],
[
'tops',
'bags_cases',
'drinks',
],
'drinks',
],
'variations with matching no match' => [
'shorts',
[
'variations' => [
'matching' => FALSE,
],
],
[
'tops',
'bags_cases',
'drinks',
],
'shorts',
],
];
}
/**
* Tests that exception is thrown when input is not an array.
*
* @dataProvider providerTestWrongType
*/
public function testWrongType($value) {
$configuration = [];
$this->plugin = new ResolveProductVariationType($configuration, 'map', []);
$type = gettype($value);
$this
->expectExceptionMessage(sprintf("Input should be an string, instead it was of type '%s'", $type));
$this->plugin
->transform($value, $this->migrateExecutable, $this->row, 'foo');
}
/**
* Data provider for testWrongType().
*/
public function providerTestWrongType() {
$object = (object) [
'one' => 'test1',
'two' => 'test2',
'three' => 'test3',
];
return [
'integer' => [
1,
],
'float' => [
1.0,
],
'NULL' => [
NULL,
],
'boolean' => [
TRUE,
],
'object' => [
$object,
],
];
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateProcessTestCase:: |
protected | property | ||
MigrateProcessTestCase:: |
protected | property | ||
MigrateProcessTestCase:: |
protected | property | ||
MigrateProcessTestCase:: |
protected | function |
Overrides UnitTestCase:: |
19 |
MigrateTestCase:: |
protected | property | The migration ID map. | |
MigrateTestCase:: |
protected | property | An array of migration configuration values. | 16 |
MigrateTestCase:: |
protected | property | Local store for mocking setStatus()/getStatus(). | |
MigrateTestCase:: |
protected | function | Generates a table schema from a row. | |
MigrateTestCase:: |
protected | function | Gets an SQLite database connection object for use in tests. | |
MigrateTestCase:: |
protected | function | Retrieves a mocked migration. | 1 |
MigrateTestCase:: |
protected | function | Gets the value on a row for a given key. | 1 |
MigrateTestCase:: |
public | function | Tests a query. | |
MigrateTestCase:: |
protected | function | Asserts tested values during test retrieval. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
ResolveProductVariationTypeTest:: |
public | function | Data provider for testTransform(). | |
ResolveProductVariationTypeTest:: |
public | function | Data provider for testWrongType(). | |
ResolveProductVariationTypeTest:: |
public | function | Tests valid values. | |
ResolveProductVariationTypeTest:: |
public | function | Tests that exception is thrown when input is not an array. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |