You are here

protected function MigrateSqlIdMapEnsureTablesTest::runEnsureTablesTest in Drupal 8

Actually run the test.

Parameters

array $schema: The mock schema object with expectations set. The Sql constructor calls ensureTables() which in turn calls this object and the expectations on it are the actual test and there are no additional asserts added.

2 calls to MigrateSqlIdMapEnsureTablesTest::runEnsureTablesTest()
MigrateSqlIdMapEnsureTablesTest::testEnsureTablesExist in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php
Tests the ensureTables method when the tables exist.
MigrateSqlIdMapEnsureTablesTest::testEnsureTablesNotExist in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php
Tests the ensureTables method when the tables do not exist.

File

core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php, line 200

Class

MigrateSqlIdMapEnsureTablesTest
Tests the SQL ID map plugin ensureTables() method.

Namespace

Drupal\Tests\migrate\Unit

Code

protected function runEnsureTablesTest($schema) {
  $database = $this
    ->getMockBuilder('Drupal\\Core\\Database\\Connection')
    ->disableOriginalConstructor()
    ->getMock();
  $database
    ->expects($this
    ->any())
    ->method('schema')
    ->willReturn($schema);
  $migration = $this
    ->getMigration();
  $plugin = $this
    ->createMock('Drupal\\migrate\\Plugin\\MigrateSourceInterface');
  $plugin
    ->expects($this
    ->any())
    ->method('getIds')
    ->willReturn([
    'source_id_property' => [
      'type' => 'integer',
    ],
    'source_id_property_2' => [
      'type' => 'integer',
    ],
  ]);
  $migration
    ->expects($this
    ->any())
    ->method('getSourcePlugin')
    ->willReturn($plugin);
  $plugin = $this
    ->createMock('Drupal\\migrate\\Plugin\\MigrateSourceInterface');
  $plugin
    ->expects($this
    ->any())
    ->method('getIds')
    ->willReturn([
    'destination_id_property' => [
      'type' => 'string',
    ],
  ]);
  $migration
    ->expects($this
    ->any())
    ->method('getDestinationPlugin')
    ->willReturn($plugin);

  /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher */
  $event_dispatcher = $this
    ->createMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
  $map = new TestSqlIdMap($database, [], 'sql', [], $migration, $event_dispatcher);
  $map
    ->getDatabase();
}