You are here

public function MediaMigrationDatabaseTraitTest::testGetFileEntityBaseQuery in Media Migration 8

@covers ::getFileEntityBaseQuery

@dataProvider providerTest

File

tests/src/Kernel/Plugin/migrate/source/d7/MediaMigrationDatabaseTraitTest.php, line 54

Class

MediaMigrationDatabaseTraitTest
@coversDefaultClass \Drupal\media_migration\Plugin\migrate\source\d7\MediaMigrationDatabaseTrait

Namespace

Drupal\Tests\media_migration\Kernel\Plugin\migrate\source\d7

Code

public function testGetFileEntityBaseQuery(array $db_records, array $expected_results) {
  $class = new TestMediaMigrationDatabaseTrait();

  // Add records to the source database.
  $this
    ->updateSourceDbWithFileTypeColumn();
  $this
    ->addRecordsToSourceDatabase($db_records);
  $query = $class
    ->getFileEntityBaseQuery($this->sourceDatabase, FALSE);
  $query
    ->fields('fm', [
    'fid',
    'filename',
  ])
    ->orderBy('fm.fid');
  $results = $query
    ->execute()
    ->fetchAll(\PDO::FETCH_ASSOC);
  $this
    ->assertEquals($expected_results['File entity'], $results);
}