class AttributeDestinationTest in Commerce Migrate 3.0.x
Same name and namespace in other branches
- 8.2 modules/csv_example/tests/src/Unit/Plugin/migrate/process/AttributeDestinationTest.php \Drupal\Tests\commerce_migrate_csv_example\Unit\Plugin\migrate\process\AttributeDestinationTest
- 3.1.x modules/csv_example/tests/src/Unit/Plugin/migrate/process/AttributeDestinationTest.php \Drupal\Tests\commerce_migrate_csv_example\Unit\Plugin\migrate\process\AttributeDestinationTest
Tests the Attribute Destination process plugin.
@coversDefaultClass \Drupal\commerce_migrate_csv_example\Plugin\migrate\process\AttributeDestination
@group commerce_migrate_csv_example
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, PhpUnitCompatibilityTrait, PhpUnitWarnings
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
- class \Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase
- class \Drupal\Tests\commerce_migrate_csv_example\Unit\Plugin\migrate\process\AttributeDestinationTest
- class \Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
Expanded class hierarchy of AttributeDestinationTest
File
- modules/
csv_example/ tests/ src/ Unit/ Plugin/ migrate/ process/ AttributeDestinationTest.php, line 16
Namespace
Drupal\Tests\commerce_migrate_csv_example\Unit\Plugin\migrate\processView source
class AttributeDestinationTest extends MigrateProcessTestCase {
/**
* Tests Attribute Destination plugin.
*
* @dataProvider providerTestAttributeDestination
*/
public function testAttributeDestination($value = NULL, $expected = NULL) {
$configuration = [];
$this->row = $this
->getMockBuilder('Drupal\\migrate\\Row')
->setMethods([
'get',
])
->disableOriginalConstructor()
->getMock();
$this->row
->expects($this
->once())
->method('get')
->with("attribute_{$value[0]}")
->willReturn($value[1]);
$this->plugin = new AttributeDestination($configuration, 'map', []);
$this->plugin
->transform($value, $this->migrateExecutable, $this->row, 'foo');
$property = $this->row
->get($expected[0]);
$this
->assertSame($expected[1], $property);
}
/**
* Data provider for testAttributeDestination().
*/
public function providerTestAttributeDestination() {
return [
'one' => [
[
'able',
'baker',
],
[
'attribute_able',
'baker',
],
],
];
}
/**
* Tests that exception is thrown when input is not valid.
*
* @dataProvider providerTestInvalidValue
*/
public function testInvalidValue($value = NULL) {
$this
->expectException(MigrateException::class);
$this
->expectExceptionMessage("There must be an even number of input values.");
$this->plugin = new AttributeDestination([], 'test_format_date', []);
$this->plugin
->transform($value, $this->migrateExecutable, $this->row, 'foo');
}
/**
* Data provider for testInvalidValue().
*/
public function providerTestInvalidValue() {
return [
'one argument' => [
[
'a',
],
],
'three arguments' => [
[
'a',
'b',
'c',
],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AttributeDestinationTest:: |
public | function | Data provider for testAttributeDestination(). | |
AttributeDestinationTest:: |
public | function | Data provider for testInvalidValue(). | |
AttributeDestinationTest:: |
public | function | Tests Attribute Destination plugin. | |
AttributeDestinationTest:: |
public | function | Tests that exception is thrown when input is not valid. | |
MigrateProcessTestCase:: |
protected | property | ||
MigrateProcessTestCase:: |
protected | property | ||
MigrateProcessTestCase:: |
protected | property | ||
MigrateProcessTestCase:: |
protected | function |
Overrides UnitTestCase:: |
17 |
MigrateTestCase:: |
protected | property | The migration ID map. | |
MigrateTestCase:: |
protected | property | An array of migration configuration values. | 7 |
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. | |
MigrateTestCase:: |
protected | function | Gets the value on a row for a given key. | |
MigrateTestCase:: |
public | function | Tests a query. | |
MigrateTestCase:: |
protected | function | Asserts tested values during test retrieval. | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
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 | 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. | |
UnitTestCase:: |
public static | function |