class AttributeDestinationTest in Commerce Migrate 8.2
Same name and namespace in other branches
- 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
- 3.0.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 PhpunitCompatibilityTrait
- 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:: |
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. | |
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. |