You are here

protected function HighWaterTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Kernel/HighWaterTest.php \Drupal\Tests\migrate\Kernel\HighWaterTest::setUp()
  2. 10 core/modules/migrate/tests/src/Kernel/HighWaterTest.php \Drupal\Tests\migrate\Kernel\HighWaterTest::setUp()

Overrides MigrateTestBase::setUp

File

core/modules/migrate/tests/src/Kernel/HighWaterTest.php, line 27

Class

HighWaterTest
Tests migration high water property.

Namespace

Drupal\Tests\migrate\Kernel

Code

protected function setUp() : void {
  parent::setUp();

  // Create source test table.
  $this->sourceDatabase
    ->schema()
    ->createTable('high_water_node', [
    'fields' => [
      'id' => [
        'description' => 'Serial',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'changed' => [
        'description' => 'Highwater',
        'type' => 'int',
        'unsigned' => TRUE,
      ],
      'title' => [
        'description' => 'Title',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ],
    ],
    'primary key' => [
      'id',
    ],
    'description' => 'Contains nodes to import',
  ]);

  // Add 3 items to source table.
  $this->sourceDatabase
    ->insert('high_water_node')
    ->fields([
    'title',
    'changed',
  ])
    ->values([
    'title' => 'Item 1',
    'changed' => 1,
  ])
    ->values([
    'title' => 'Item 2',
    'changed' => 2,
  ])
    ->values([
    'title' => 'Item 3',
    'changed' => 3,
  ])
    ->execute();
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('user');
  $this
    ->installSchema('node', 'node_access');
  $this
    ->executeMigration('high_water_test');
}