コード例 #1
0
 /**
  * Tests migration of user variables to user.settings.yml.
  */
 public function testUserSettings()
 {
     $config = $this->config('user.settings');
     $this->assertIdentical(TRUE, $config->get('notify.status_blocked'));
     $this->assertIdentical(FALSE, $config->get('notify.status_activated'));
     $this->assertIdentical(FALSE, $config->get('verify_mail'));
     $this->assertIdentical('admin_only', $config->get('register'));
     $this->assertIdentical('Guest', $config->get('anonymous'));
     // Tests migration of user_register using the AccountSettingsForm.
     // Map D6 value to D8 value
     $user_register_map = [[0, USER_REGISTER_ADMINISTRATORS_ONLY], [1, USER_REGISTER_VISITORS], [2, USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL]];
     foreach ($user_register_map as $map) {
         // Tests migration of user_register = 1
         Database::getConnection('default', 'migrate')->update('variable')->fields(['value' => serialize($map[0])])->condition('name', 'user_register')->execute();
         /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
         $migration = $this->getMigration('d6_user_settings');
         // Indicate we're rerunning a migration that's already run.
         $migration->getIdMap()->prepareUpdate();
         $this->executeMigration($migration);
         $form = $this->container->get('form_builder')->getForm(AccountSettingsForm::create($this->container));
         $this->assertIdentical($map[1], $form['registration_cancellation']['user_register']['#value']);
     }
 }
コード例 #2
0
 protected function setUp()
 {
     parent::setUp();
     $this->form = AccountSettingsForm::create($this->container);
     $this->values = array('anonymous' => array('#value' => $this->randomString(10), '#config_name' => 'user.settings', '#config_key' => 'anonymous'), 'user_mail_cancel_confirm_body' => array('#value' => $this->randomString(), '#config_name' => 'user.mail', '#config_key' => 'cancel_confirm.body'), 'user_mail_cancel_confirm_subject' => array('#value' => $this->randomString(20), '#config_name' => 'user.mail', '#config_key' => 'cancel_confirm.subject'), 'register_pending_approval_admin_body' => array('#value' => $this->randomString(), '#config_name' => 'user.mail', '#config_key' => 'register_pending_approval_admin.body'), 'register_pending_approval_admin_subject' => array('#value' => $this->randomString(20), '#config_name' => 'user.mail', '#config_key' => 'register_pending_approval_admin.subject'));
 }