You are here

class MigrateUpgradeDrushRunnerTest in Migrate Upgrade 8.3

Tests for the MigrateUpgradeDrushRunner class.

@group migrate_upgrade @coversDefaultClass \Drupal\migrate_upgrade\MigrateUpgradeDrushRunner

Hierarchy

Expanded class hierarchy of MigrateUpgradeDrushRunnerTest

File

tests/src/Unit/MigrateUpgradeDrushRunnerTest.php, line 15

Namespace

Drupal\Tests\migrate_upgrade\Unit
View 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

Namesort descending Modifiers Type Description Overrides
MigrateTestCase::$idMap protected property The migration ID map.
MigrateTestCase::$migrationConfiguration protected property An array of migration configuration values. 16
MigrateTestCase::$migrationStatus protected property Local store for mocking setStatus()/getStatus().
MigrateTestCase::createSchemaFromRow protected function Generates a table schema from a row.
MigrateTestCase::getDatabase protected function Gets an SQLite database connection object for use in tests.
MigrateTestCase::getMigration protected function Retrieves a mocked migration. 1
MigrateTestCase::getValue protected function Gets the value on a row for a given key. 1
MigrateTestCase::queryResultTest public function Tests a query.
MigrateTestCase::retrievalAssertHelper protected function Asserts tested values during test retrieval.
MigrateUpgradeDrushRunnerTest::getData public function Returns test data for the test.
MigrateUpgradeDrushRunnerTest::testIdSubstitution public function Test the id substitution functions.
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUp protected function 340