class MigrateUpgradeDrushRunnerTest in Migrate Upgrade 8.3
Tests for the MigrateUpgradeDrushRunner class.
@group migrate_upgrade @coversDefaultClass \Drupal\migrate_upgrade\MigrateUpgradeDrushRunner
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
- class \Drupal\Tests\migrate_upgrade\Unit\MigrateUpgradeDrushRunnerTest
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
Expanded class hierarchy of MigrateUpgradeDrushRunnerTest
File
- tests/
src/ Unit/ MigrateUpgradeDrushRunnerTest.php, line 15
Namespace
Drupal\Tests\migrate_upgrade\UnitView source
class MigrateUpgradeDrushRunnerTest extends MigrateTestCase {
/**
* Test the id substitution functions.
*
* @param array $source
* The source data.
* @param array $expected
* The expected results.
*
* @covers ::substituteIds
* @covers ::substituteMigrationIds
*
* @dataProvider getData
*/
public function testIdSubstitution(array $source, array $expected) : void {
$loggerProphet = $this
->prophesize(LoggerInterface::class);
$runner = new TestMigrateUpgradeDrushRunner($loggerProphet
->reveal());
$results = $runner
->substituteIds($source);
$this
->assertSame($expected, $results);
}
/**
* Returns test data for the test.
*
* @return array
* The test data.
*/
public function getData() : array {
return [
'Single Migration Lookup' => [
'source_data' => [
'id' => 'my_migration',
'process' => [
'element' => [
'plugin' => 'migration_lookup',
'migration' => 'my_previous_migration',
'source' => 'value',
],
],
'migration_dependencies' => [
'required' => [
'my_previous_migration',
'required_dependency',
],
'optional' => [
'optional_dependency',
],
],
],
'expected_result' => [
'id' => 'upgrade_my_migration',
'process' => [
'element' => [
'plugin' => 'migration_lookup',
'migration' => 'upgrade_my_previous_migration',
'source' => 'value',
],
],
'migration_dependencies' => [
'required' => [
'upgrade_my_previous_migration',
'upgrade_required_dependency',
],
'optional' => [
'upgrade_optional_dependency',
],
],
],
],
'Dual Migration Lookup' => [
'source_data' => [
'id' => 'my_migration',
'process' => [
'element' => [
'plugin' => 'migration_lookup',
'migration' => [
'my_previous_migration_1',
'my_previous_migration_2',
],
'source_ids' => [
'my_previous_migration_1' => [
'source_1',
],
'my_previous_migration_2' => [
'source_2',
],
],
'source' => 'value',
],
],
'migration_dependencies' => [
'required' => [
'my_previous_migration_1',
'required_dependency',
],
'optional' => [
'my_previous_migration_2',
'optional_dependency',
],
],
],
'expected_result' => [
'id' => 'upgrade_my_migration',
'process' => [
'element' => [
'plugin' => 'migration_lookup',
'migration' => [
'upgrade_my_previous_migration_1',
'upgrade_my_previous_migration_2',
],
'source_ids' => [
'upgrade_my_previous_migration_1' => [
'source_1',
],
'upgrade_my_previous_migration_2' => [
'source_2',
],
],
'source' => 'value',
],
],
'migration_dependencies' => [
'required' => [
'upgrade_my_previous_migration_1',
'upgrade_required_dependency',
],
'optional' => [
'upgrade_my_previous_migration_2',
'upgrade_optional_dependency',
],
],
],
],
'Derivative Migration Lookup' => [
'source_data' => [
'id' => 'my_migration',
'process' => [
'element' => [
'plugin' => 'migration_lookup',
'migration' => 'derivable_migration',
'source' => 'value',
],
],
'migration_dependencies' => [
'required' => [
'derivable_migration',
'required_dependency',
],
'optional' => [
'optional_dependency',
],
],
],
'expected_result' => [
'id' => 'upgrade_my_migration',
'process' => [
'element' => [
'plugin' => 'migration_lookup',
'migration' => [
'upgrade_derivable_migration_derivitive_1',
'upgrade_derivable_migration_derivitive_2',
],
'source' => 'value',
],
],
'migration_dependencies' => [
'required' => [
'upgrade_derivable_migration_derivitive_1',
'upgrade_derivable_migration_derivitive_2',
'upgrade_required_dependency',
],
'optional' => [
'upgrade_optional_dependency',
],
],
],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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. | |
MigrateUpgradeDrushRunnerTest:: |
public | function | Returns test data for the test. | |
MigrateUpgradeDrushRunnerTest:: |
public | function | Test the id substitution functions. | |
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. | |
UnitTestCase:: |
protected | function | 340 |