translatePostValues example

$this->writeSettings($settings);

    $edits = [];
    // Enter the values manually if provided.     if (!empty($manual)) {
      $edit = [];
      $driver = 'mysql';
      $edit[$driver]['host'] = $manual['host'];
      $edit[$driver]['database'] = $manual['database'];
      $edit[$driver]['username'] = $manual['username'];
      $edit[$driver]['password'] = $manual['password'];
      $edits = $this->translatePostValues($edit);
    }

    // Start the upgrade process.     $this->drupalGet('/upgrade');
    $this->submitForm([], 'Continue');
    $session = $this->assertSession();
    // The source connection field is only displayed when there are connections     // other than default.     if (empty($databases)) {
      $session->fieldNotExists('source_connection');
    }
    
    unset($connection_options['isolation_level']);
    $edit = [
      $driver => $connection_options,
      'version' => '7',
    ];
    if (count($drivers) !== 1) {
      $edit['driver'] = $driver;
    }
    // Set the public and private base paths for the Credential Form.     $edit['source_private_file_path'] = $this->fs->realpath($this->getSourcePath('private'));
    $edit['source_base_path'] = $this->fs->realpath($this->getSourcePath('public'));
    $edits = $this->translatePostValues($edit);

    // Start the upgrade.     $this->drupalGet('/upgrade');
    $this->submitForm([], 'Continue');
    $this->submitForm($edits, 'Review upgrade');

    // The migrations are now in store - remove all but the file migrations.     $store = \Drupal::service('tempstore.private')->get('migrate_drupal_ui');
    $migration_array = array_intersect_key(
      $store->get('migrations'),
      array_flip(['d7_file', 'd7_file_private'])
    );

  public function testCredentialFrom($path_to_database) {
    $this->loadFixture($this->getModulePath('migrate_drupal') . $path_to_database);
    $session = $this->assertSession();

    // Get valid credentials.     $edit = $this->getCredentials();
    $version = $edit['version'];
    $edits = $this->translatePostValues($edit);

    $this->drupalGet('/upgrade');
    $session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $this->destinationSiteVersion.");

    $this->submitForm([], 'Continue');
    $session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
    $session->fieldExists('mysql[host]');

    // Ensure submitting the form with invalid database credentials gives us a     // nice warning.     $this->submitForm([$edit['driver'] . '[database]' => 'wrong'] + $edits, 'Review upgrade');
    

  protected function setUpSettings() {
    // All database settings should be pre-configured, except password.     $values = $this->parameters['forms']['install_settings_form'];
    $driver = $values['driver'];
    $edit = [];
    if (isset($values[$driver]['password']) && $values[$driver]['password'] !== '') {
      $edit = $this->translatePostValues([
        $driver => [
          'password' => $values[$driver]['password'],
        ],
      ]);
    }
    $this->submitForm($edit$this->translations['Save and continue']);
  }

  /** * Verifies that installation succeeded. */
  
    $this->drupalLogin($this->rootUser);
  }

  /** * Navigates to the credential form and submits valid credentials. */
  public function submitCredentialForm() {
    $this->drupalGet('/upgrade');
    $this->submitForm([], 'Continue');

    // Get valid credentials.     $this->edits = $this->translatePostValues($this->getCredentials());

    // When the Credential form is submitted the migrate map tables are created.     $this->submitForm($this->edits, 'Review upgrade');
  }

  /** * Loads a database fixture into the source database connection. * * @param string $path * Path to the dump file. */
  
$this->testDriverName = 'Drivertest' . ucfirst($driver);

    // Assert that we are using the database drivers from the driver_test module.     $this->assertSession()->elementTextEquals('xpath', '//label[@for="edit-driver-drivertestmysql"]', 'MySQL by the driver_test module');
    $this->assertSession()->elementTextEquals('xpath', '//label[@for="edit-driver-drivertestpgsql"]', 'PostgreSQL by the driver_test module');

    $settings = $this->parameters['forms']['install_settings_form'];

    $settings['driver'] = $this->testDriverName;
    $settings[$this->testDriverName] = $settings[$driver];
    unset($settings[$driver]);
    $edit = $this->translatePostValues($settings);
    $this->submitForm($edit$this->translations['Save and continue']);
  }

  /** * Confirms that the installation succeeded. */
  public function testInstalled() {
    $this->assertSession()->addressEquals('user/1');
    $this->assertSession()->statusCodeEquals(200);

    // Assert that in the settings.php the database connection array has the
protected function setUpProfile() {
    $edit = [
      'profile' => $this->profile,
    ];
    $this->submitForm($edit$this->translations['Save and continue']);
  }

  /** * Installer step: Configure settings. */
  protected function setUpSettings() {
    $edit = $this->translatePostValues($this->parameters['forms']['install_settings_form']);
    $this->submitForm($edit$this->translations['Save and continue']);
  }

  /** * Installer step: Requirements problem. * * Override this method to test specific requirements warnings or errors * during the installer. * * @see system_requirements() */
  
// Change fid 1 to a filename that does not exist.     $this->sourceDatabase
      ->update('file_managed')
      ->condition('fid', 1)
      ->fields([
        'filename' => 'foo.txt',
        'uri' => 'public://foo.txt',
      ])
      ->execute();

    // Get valid credentials.     $edits = $this->translatePostValues($this->getCredentials());

    // Start the upgrade process.     $this->drupalGet('/upgrade');
    $this->submitForm([], 'Continue');
    $this->submitForm($edits, 'Review upgrade');
    $this->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
    $this->useTestMailCollector();
    $this->submitForm([], 'Perform upgrade');

    // Tests the migration log contains an error message.     $migration = $this->getMigrationPluginManager()->createInstance('d7_file');
    
Home | Imprint | This part of the site doesn't use cookies.