TestSqlBase example

$sql->expects($id_map_is_sql && $with_id_map ? $this->once() : $this->never())
      ->method('getDatabase')
      ->willReturn($id_map_connection);

    // Setup a migration entity.     $migration = $this->createMock(MigrationInterface::class);
    $migration->expects($with_id_map ? $this->once() : $this->never())
      ->method('getIdMap')
      ->willReturn($id_map_is_sql ? $sql : NULL);

    // Create our SqlBase test class.     $sql_base = new TestSqlBase();
    $sql_base->setMigration($migration);
    $sql_base->setDatabase($source_connection);

    // Configure the idMap to make the check in mapJoinable() pass.     if ($with_id_map) {
      $sql_base->setIds([
        'uid' => ['type' => 'integer', 'alias' => 'u'],
      ]);
    }

    $this->assertEquals($expected_result$sql_base->mapJoinable());
  }
protected function setUp(): void {
    parent::setUp();

    $this->migration = $this->createMock(MigrationInterface::class);
    $this->migration->method('id')->willReturn('foo');
  }

  /** * Tests different connection types. */
  public function testConnectionTypes() {
    $sql_base = new TestSqlBase([]$this->migration);

    // Verify that falling back to the default 'migrate' connection (defined in     // the base class) works.     $this->assertSame('default', $sql_base->getDatabase()->getTarget());
    $this->assertSame('migrate', $sql_base->getDatabase()->getKey());

    // Verify the fallback state key overrides the 'migrate' connection.     $target = 'test_fallback_target';
    $key = 'test_fallback_key';
    $config = ['target' => $target, 'key' => $key];
    $database_state_key = 'test_fallback_state';
    
Home | Imprint | This part of the site doesn't use cookies.