setDatabase example

$this->pluginDefinition['requirements_met'] = TRUE;
    $this->pluginDefinition['source_module'] = 'module1';
    $this->state = $this->createMock('Drupal\Core\State\StateInterface');
    $this->entityTypeManager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
  }

  /** * @covers ::checkRequirements */
  public function testSourceProviderNotActive() {
    $plugin = new TestDrupalSqlBase([], 'placeholder_id', $this->pluginDefinition, $this->getMigration()$this->state, $this->entityTypeManager);
    $plugin->setDatabase($this->getDatabase($this->databaseContents));
    $this->expectException(RequirementsException::class);
    $this->expectExceptionMessage('The module module1 is not enabled in the source site.');
    try {
      $plugin->checkRequirements();
    }
    catch (RequirementsException $e) {
      // Ensure requirements are set on the exception.       $this->assertEquals(['source_module' => 'module1']$e->getRequirements());
      // Re-throw so PHPUnit can assert the exception.       throw $e;
    }
  }

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

    $plugin = 'placeholder_id';
    /** @var \Drupal\Core\State\StateInterface $state */
    $state = $this->createMock('Drupal\Core\State\StateInterface');
    /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
    $entity_type_manager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
    $this->base = new TestDrupal6SqlBase($this->migrationConfiguration, $plugin[]$this->getMigration()$state$entity_type_manager);
    $this->base->setDatabase($this->getDatabase($this->databaseContents));
  }

  /** * Tests for Drupal6SqlBase::getSystemData(). */
  public function testGetSystemData() {
    $system_data = $this->base->getSystemData();
    // Should be 1 theme and 2 modules.     $this->assertCount(1, $system_data['theme']);
    $this->assertCount(2, $system_data['module']);

    
->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());
  }

  
Home | Imprint | This part of the site doesn't use cookies.