function SqlBaseTest::prepareSourceData

Creates a custom source table and some sample data.

1 call to SqlBaseTest::prepareSourceData()
SqlBaseTest::testPrepareQuery in core/modules/migrate/tests/src/Kernel/SqlBaseTest.php
Tests prepare query method.

File

core/modules/migrate/tests/src/Kernel/SqlBaseTest.php, line 232

Class

SqlBaseTest
Tests the functionality of SqlBase.

Namespace

Drupal\Tests\migrate\Kernel

Code

protected function prepareSourceData() : void {
    $this->sourceDatabase
        ->schema()
        ->createTable('migrate_source_test', [
        'fields' => [
            'id' => [
                'type' => 'int',
            ],
            'name' => [
                'type' => 'varchar',
                'length' => 32,
            ],
        ],
    ]);
    // Add some data in the table.
    $this->sourceDatabase
        ->insert('migrate_source_test')
        ->fields([
        'id',
        'name',
    ])
        ->values([
        'id' => 1,
        'name' => 'foo',
    ])
        ->values([
        'id' => 2,
        'name' => 'bar',
    ])
        ->values([
        'id' => 3,
        'name' => 'baz',
    ])
        ->execute();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.