/**
  * Test soft blocking.
  */
 public function testSoftBlocking()
 {
     // Allow 3 attempts to login before being soft-blocking is enforced.
     $config = \Drupal::configFactory()->getEditable('login_security.settings');
     $config->set('user_wrong_count', 0)->save();
     $config->set('host_wrong_count', 2)->save();
     // Remove notices.
     $config->set('notice_attempts_available', 0)->save();
     $normal_user = $this->drupalCreateUser();
     $good_pass = $normal_user->getPassword();
     // Intentionally break the password to repeat invalid logins.
     $new_pass = user_password();
     $normal_user->setPassword($new_pass);
     $site_name = \Drupal::config('system.site')->get('name');
     // First try.
     $this->assertNoSoftBlocked($normal_user);
     // Second try.
     $this->assertNoSoftBlocked($normal_user);
     // Remove error messages display.
     $config->set('disable_core_login_error', 1)->save();
     // Third try, still valid without soft blocking.
     $this->assertNoSoftBlocked($normal_user);
     // Restore error messages.
     $config->set('disable_core_login_error', 0)->save();
     // 4th attempt, the host is not allowed this time.
     $this->assertSoftBlocked($normal_user);
     // Try a normal login because it should be locked out now.
     $normal_user->setPassword($good_pass);
     $this->assertSoftBlocked($normal_user);
 }
Ejemplo n.º 2
0
 /**
  * Test user registration integration.
  */
 public function testUserRegisterForm()
 {
     $id = $this->type->id();
     $field_name = $this->field->getName();
     $this->field->setRequired(TRUE);
     $this->field->save();
     // Allow registration without administrative approval and log in user
     // directly after registering.
     \Drupal::configFactory()->getEditable('user.settings')->set('register', USER_REGISTER_VISITORS)->set('verify_mail', 0)->save();
     user_role_grant_permissions(AccountInterface::AUTHENTICATED_ROLE, ['view own test profile']);
     // Verify that the additional profile field is attached and required.
     $name = $this->randomMachineName();
     $pass_raw = $this->randomMachineName();
     $edit = ['name' => $name, 'mail' => $this->randomMachineName() . '@example.com', 'pass[pass1]' => $pass_raw, 'pass[pass2]' => $pass_raw];
     $this->drupalPostForm('user/register', $edit, t('Create new account'));
     $this->assertRaw(new FormattableMarkup('@name field is required.', ['@name' => $this->field->getLabel()]));
     // Verify that we can register.
     $edit["entity_" . $id . "[{$field_name}][0][value]"] = $this->randomMachineName();
     $this->drupalPostForm(NULL, $edit, t('Create new account'));
     $this->assertText(new FormattableMarkup('Registration successful. You are now logged in.', []));
     $new_user = user_load_by_name($name);
     $this->assertTrue($new_user->isActive(), 'New account is active after registration.');
     // Verify that a new profile was created for the new user ID.
     $profile = \Drupal::entityTypeManager()->getStorage('profile')->loadByUser($new_user, $this->type->id());
     $this->assertEqual($profile->get($field_name)->value, $edit["entity_" . $id . "[{$field_name}][0][value]"], 'Field value found in loaded profile.');
     // Verify that the profile field value appears on the user account page.
     $this->drupalGet('user');
     $this->assertText($edit["entity_" . $id . "[{$field_name}][0][value]"], 'Field value found on user account page.');
 }
Ejemplo n.º 3
0
 /**
  * Get subscription status from the Acquia Network, and store the result.
  *
  * This check also sends a heartbeat to the Acquia Network unless
  * $params['no_heartbeat'] == 1.
  *
  * @param array $params
  *
  * @return FALSE, integer (error number), or subscription data.
  */
 static function update($params = array())
 {
     $config = \Drupal::configFactory()->getEditable('acquia_connector.settings');
     $current_subscription = $config->get('subscription_data');
     $subscription = FALSE;
     if (!self::hasCredentials()) {
         // If there is not an identifier or key, delete any old subscription data.
         $config->clear('subscription_data')->set('subscription_data', ['active' => FALSE])->save();
     } else {
         // Get our subscription data
         try {
             $subscription = \Drupal::service('acquia_connector.client')->getSubscription($config->get('identifier'), $config->get('key'), $params);
         } catch (ConnectorException $e) {
             switch ($e->getCustomMessage('code')) {
                 case static::NOT_FOUND:
                 case static::EXPIRED:
                     // Fall through since these values are stored and used by
                     // acquia_search_acquia_subscription_status()
                     $subscription = $e->getCustomMessage('code');
                     break;
                 default:
                     // Likely server error (503) or connection timeout (-110) so leave
                     // current subscription in place. _acquia_agent_request() logged an
                     // error message.
                     return $current_subscription;
             }
         }
         if ($subscription) {
             \Drupal::moduleHandler()->invokeAll('acquia_subscription_status', [$subscription]);
             $config->set('subscription_data', $subscription)->save();
         }
     }
     return $subscription;
 }
 /**
  * Confirm the config defaults show on the translations page.
  */
 public function testConfigTranslationsExist()
 {
     // Ensure the config shows on the admin form.
     $this->drupalGet('admin/config/regional/config-translation');
     $this->assertResponse(200);
     $this->assertText(t('Metatag defaults'));
     // Load the main metatag_defaults config translation page.
     $this->drupalGet('admin/config/regional/config-translation/metatag_defaults');
     $this->assertResponse(200);
     // @todo Update this to confirm the H1 is loaded.
     $this->assertRaw(t('Metatag defaults'));
     // Load all of the Metatag defaults.
     $defaults = \Drupal::configFactory()->listAll('metatag.metatag_defaults');
     /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
     $config_manager = \Drupal::service('config.manager');
     // Confirm each of the configs is available on the translation form.
     foreach ($defaults as $config_name) {
         if ($config_entity = $config_manager->loadConfigEntityByName($config_name)) {
             $this->assertText($config_entity->label());
         }
     }
     // Confirm that each config translation page can be loaded.
     foreach ($defaults as $config_name) {
         if ($config_entity = $config_manager->loadConfigEntityByName($config_name)) {
             $this->drupalGet('admin/config/search/metatag/' . $config_entity->id() . '/translate');
             $this->assertResponse(200);
         } else {
             $this->error('Unable to load a Metatag default config: ' . $config_name);
         }
     }
 }
Ejemplo n.º 5
0
 public function testUserHooks()
 {
     FieldStorageConfig::create(array('field_name' => 'field_text', 'type' => 'string', 'entity_type' => 'user'))->save();
     FieldConfig::create(array('field_name' => 'field_text', 'type' => 'string', 'entity_type' => 'user', 'bundle' => 'user'))->save();
     $this->assertIdentical('', \Drupal::config('name.settings')->get('user_preferred'));
     FieldStorageConfig::create(array('field_name' => 'field_name_test', 'type' => 'name', 'entity_type' => 'user'))->save();
     FieldStorageConfig::create(array('field_name' => 'field_name_test2', 'type' => 'name', 'entity_type' => 'user'))->save();
     $field = FieldConfig::create(array('field_name' => 'field_name_test', 'type' => 'name', 'entity_type' => 'user', 'bundle' => 'user'));
     $field->save();
     $field2 = FieldConfig::create(array('field_name' => 'field_name_test2', 'type' => 'name', 'entity_type' => 'user', 'bundle' => 'user'));
     $field2->save();
     $this->assertEqual($field->getName(), \Drupal::config('name.settings')->get('user_preferred'));
     \Drupal::configFactory()->getEditable('name.settings')->set('user_preferred', $field2->getName())->save();
     $field2->delete();
     $this->assertEqual('', \Drupal::config('name.settings')->get('user_preferred'));
     \Drupal::configFactory()->getEditable('name.settings')->set('user_preferred', $field->getName())->save();
     $account = User::create(array('name' => 'test'));
     $account->field_name_test[0] = array('given' => 'Max', 'family' => 'Mustermann');
     $account->save();
     $account = User::load($account->id());
     $this->assertEqual('Max Mustermann', $account->realname);
     $this->assertEqual('Max Mustermann', user_format_name($account));
     $this->assertEqual('test', $account->getUsername());
     $this->assertEqual('Max Mustermann', $account->getDisplayName());
 }
Ejemplo n.º 6
0
  public function testAjaxWithAdminRoute() {
    \Drupal::service('theme_installer')->install(['stable', 'seven']);
    $theme_config = \Drupal::configFactory()->getEditable('system.theme');
    $theme_config->set('admin', 'seven');
    $theme_config->set('default', 'stable');
    $theme_config->save();

    $account = $this->drupalCreateUser(['view the administration theme']);
    $this->drupalLogin($account);

    // First visit the site directly via the URL. This should render it in the
    // admin theme.
    $this->drupalGet('admin/ajax-test/theme');
    $assert = $this->assertSession();
    $assert->pageTextContains('Current theme: seven');

    // Now click the modal, which should also use the admin theme.
    $this->drupalGet('ajax-test/dialog');
    $assert->pageTextNotContains('Current theme: stable');
    $this->clickLink('Link 8 (ajax)');
    $assert->assertWaitOnAjaxRequest();

    $assert->pageTextContains('Current theme: stable');
    $assert->pageTextNotContains('Current theme: seven');
  }
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $system_roles = user_roles($membersonly = TRUE);
     $config = \Drupal::config('registration_role_with_approval.settings');
     $site_config = \Drupal::configFactory()->get('system.mail');
     $mailing_list = $config->get('mailing_list');
     if ($mailing_list == "") {
         $mailing_list .= $site_config->get('mail');
     }
     $email_subject = $config->get('email_subject');
     $email_body = $config->get('email_body');
     $profile_roles = $config->get('profile_roles');
     $form['roles'] = array('#type' => 'fieldset', '#title' => t('Avaliable Roles on registration form'), '#collapsible' => TRUE);
     foreach ($system_roles as $system_role) {
         $role_id = $system_role->id();
         if ($role_id != '0' && $role_id != 'authenticated') {
             $form['roles'][$system_role->id()] = array('#type' => 'checkbox', '#title' => t($system_role->label()), '#default_value' => $profile_roles[$system_role->id()]['default']);
             $form['roles'][$system_role->id() . "needs_approval"] = array('#type' => 'checkbox', '#title' => t('needs approval'), '#states' => array('invisible' => array(":input[name='{$role_id}']" => array('checked' => FALSE))), '#attributes' => array('style' => 'margin-left: 2em'), '#default_value' => $profile_roles[$system_role->id()]['needs_approval']);
         }
     }
     $form['custom_mail'] = array('#type' => 'fieldset', '#title' => t('Custom registration email configuration'), '#collapsible' => TRUE);
     $form['custom_mail']['new_email'] = array("#type" => "textfield", "#title" => "Enter valid email");
     $form['custom_mail']['add_email'] = array("#type" => "button", "#value" => "Add email", "#ajax" => array('callback' => 'Drupal\\registration_role_with_approval\\Form\\RegistrationRoleWithApprovalSettingsForm::addEmailCallback', 'event' => 'click', 'effect' => 'fade', 'progress' => array('type' => 'throbber')));
     $form['custom_mail']['mailing_list'] = array("#type" => "textarea", "#title" => "Mailing list", "#default_value" => $mailing_list);
     $form['custom_mail']['email_subject'] = array("#type" => "textfield", "#title" => "Email subject", "#default_value" => $email_subject);
     $form['custom_mail']['email_body'] = array("#type" => "textarea", "#title" => "Email body", "#default_value" => $email_body);
     return parent::buildForm($form, $form_state);
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Place the tabs and actions blocks as various tests use them.
     $this->drupalPlaceBlock('local_actions_block');
     $this->drupalPlaceBlock('local_tasks_block');
     // Collect admin permissions.
     $class = get_class($this);
     $adminPermissions = [];
     while ($class) {
         if (property_exists($class, 'adminPermissions')) {
             $adminPermissions = array_merge($adminPermissions, $class::$adminPermissions);
         }
         $class = get_parent_class($class);
     }
     // Enable a random selection of 8 countries so we're not always
     // testing with US and CA.
     $countries = \Drupal::service('country_manager')->getAvailableList();
     $country_ids = array_rand($countries, 8);
     foreach ($country_ids as $country_id) {
         // Don't use the country UI, we're not testing that here...
         Country::load($country_id)->enable()->save();
     }
     // Last one of the 8 gets to be the store default country.
     \Drupal::configFactory()->getEditable('uc_store.settings')->set('address.country', $country_id)->save();
     // Create a store administrator user account.
     $this->adminUser = $this->drupalCreateUser($adminPermissions);
     // Create a test product.
     $this->product = $this->createProduct(array('uid' => $this->adminUser->id(), 'promote' => 0));
 }
Ejemplo n.º 9
0
 /**
  * Tests getDefaultConfigLangcode().
  */
 public function testGetDefaultConfigLangcode()
 {
     // Install the Language module's configuration so we can use the
     // module_installer service.
     $this->installConfig(['language']);
     $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode('locale_test_translate.settings'), 'Before installing a module the locale config manager can not access the shipped configuration.');
     \Drupal::service('module_installer')->install(['locale_test_translate']);
     $this->assertEqual('en', \Drupal::service('locale.config_manager')->getDefaultConfigLangcode('locale_test_translate.settings'), 'After installing a module the locale config manager can get the shipped configuration langcode.');
     $simple_config = \Drupal::configFactory()->getEditable('locale_test_translate.simple_config_extra');
     $simple_config->set('foo', 'bar')->save();
     $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode($simple_config->getName()), 'Simple config created through the API is not treated as shipped configuration.');
     $block = Block::create(array('id' => 'test_default_config', 'theme' => 'classy', 'status' => TRUE, 'region' => 'content', 'plugin' => 'local_tasks_block', 'settings' => ['id' => 'local_tasks_block', 'label' => $this->randomMachineName(), 'provider' => 'core', 'label_display' => FALSE, 'primary' => TRUE, 'secondary' => TRUE]));
     $block->save();
     // Install the theme after creating the block as installing the theme will
     // install the block provided by the locale_test module.
     \Drupal::service('theme_installer')->install(['classy']);
     // The test_default_config block provided by the locale_test module will not
     // be installed because a block with the same ID already exists.
     $this->installConfig(['locale_test']);
     $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode('block.block.test_default_config'), 'The block.block.test_default_config is not shipped configuration.');
     // Delete the block so we can install the one provided by the locale_test
     // module.
     $block->delete();
     $this->installConfig(['locale_test']);
     $this->assertEqual('en', \Drupal::service('locale.config_manager')->getDefaultConfigLangcode('block.block.test_default_config'), 'The block.block.test_default_config is shipped configuration.');
     // Test the special case for configurable_language config entities.
     $fr_language = ConfigurableLanguage::createFromLangcode('fr');
     $fr_language->save();
     $this->assertEqual('en', \Drupal::service('locale.config_manager')->getDefaultConfigLangcode('language.entity.fr'), 'The language.entity.fr is treated as shipped configuration because it is a configurable_language config entity and in the standard language list.');
     $custom_language = ConfigurableLanguage::createFromLangcode('custom');
     $custom_language->save();
     $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode('language.entity.custom'), 'The language.entity.custom is not shipped configuration because it is not in the standard language list.');
 }
Ejemplo n.º 10
0
 public function testCheckoutAjax()
 {
     // Enable two payment methods and set a condition on one.
     $this->createPaymentMethod('check');
     $other = $this->createPaymentMethod('other');
     // $this->addPaymentZoneCondition($other['id'], 'KS');
     // Specify that the billing zone should update the payment pane.
     $config = _uc_ajax_defaults('checkout');
     $config['panes][billing][address][zone'] = array('payment-pane' => 'payment-pane');
     \Drupal::configFactory()->getEditable('uc_cart.settings')->set('ajax.checkout', $config)->save();
     // Go to the checkout page, verify that the conditional payment method is
     // not available.
     $product = $this->createProduct(array('shippable' => 0));
     $this->addToCart($product);
     $this->drupalPostForm('cart', array('items[0][qty]' => 1), t('Checkout'));
     // @todo Re-enable when shipping quote conditions are available.
     // $this->assertNoEscaped($other['label']);
     // Change the billing zone and verify that payment pane updates.
     $edit = array();
     $edit['panes[billing][zone]'] = 'KS';
     $this->ucPostAjax(NULL, $edit, 'panes[billing][zone]');
     $this->assertEscaped($other['label']);
     $edit['panes[billing][zone]'] = 'AL';
     $this->ucPostAjax(NULL, $edit, 'panes[billing][zone]');
     // Not in Kansas any more...
     // @todo Re-enable when shipping quote conditions are available.
     // $this->assertNoEscaped($other['label']);
 }
Ejemplo n.º 11
0
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config = \Drupal::configFactory()->getEditable('cors.config');
     $config->set('cors_domains', $form_state->getValue('settings'));
     $config->save();
     drupal_set_message(t('Configuration saved successfully!'), 'status', FALSE);
 }
Ejemplo n.º 12
0
 /**
  * Code run before each and every test method.
  */
 public function setUp()
 {
     parent::setUp();
     // Restore node to default value.
     $this->node = 1;
     // Create object with configuration.
     $this->config = \Drupal::configFactory()->getEditable('geshifilter.settings');
     // And set the path to the geshi library.
     $this->config->set('geshi_dir', '/libraries/geshi');
     // Create a content type, as we will create nodes on test.
     $settings = array('type' => 'geshifilter_content_type', 'name' => 'Geshifilter Content');
     $this->drupalCreateContentType($settings);
     // Create a filter admin user.
     $permissions = array('administer filters', 'administer nodes', 'access administration pages', 'create geshifilter_content_type content', 'edit any geshifilter_content_type content', 'administer site configuration');
     $this->filterAdminUser = $this->drupalCreateUser($permissions);
     // Log in with filter admin user.
     $this->drupalLogin($this->filterAdminUser);
     // Add an text format with only geshi filter.
     $this->createTextFormat('geshifilter_text_format', array('filter_geshifilter'));
     // Set some default GeSHi filter admin settings.
     // Set default highlighting mode to "do nothing".
     $this->config->set('default_highlighting', GeshiFilter::DEFAULT_PLAINTEXT);
     $this->config->set('use_format_specific_options', FALSE);
     $this->config->set('tag_styles', array(GeshiFilter::BRACKETS_ANGLE => GeshiFilter::BRACKETS_ANGLE, GeshiFilter::BRACKETS_SQUARE => GeshiFilter::BRACKETS_SQUARE));
     $this->config->set('default_line_numbering', GeshiFilter::LINE_NUMBERS_DEFAULT_NONE);
     $this->config->save();
 }
Ejemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 protected function setup()
 {
     parent::setup();
     // Set extra fields
     \Drupal::configFactory()->getEditable('ds_extras.settings')->set('region_to_block', TRUE)->set('fields_extra', TRUE)->set('fields_extra_list', array('node|article|ds_extras_extra_test_field', 'node|article|ds_extras_second_field'))->save();
     \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
 }
 /**
  * Tests if exposed filtering via AJAX works for the "Content" View.
  */
 public function testExposedFiltering()
 {
     // Enable AJAX on the /admin/content View.
     \Drupal::configFactory()->getEditable('views.view.content')->set('display.default.display_options.use_ajax', TRUE)->save();
     // Create a Content type and two test nodes.
     $this->createContentType(['type' => 'page']);
     $this->createNode(['title' => 'Page One']);
     $this->createNode(['title' => 'Page Two']);
     // Create a user privileged enough to use exposed filters and view content.
     $user = $this->drupalCreateUser(['administer site configuration', 'access content', 'access content overview']);
     $this->drupalLogin($user);
     // Visit the View page.
     $this->drupalGet('admin/content');
     $session = $this->getSession();
     // Ensure that the Content we're testing for is present.
     $html = $session->getPage()->getHtml();
     $this->assertContains('Page One', $html);
     $this->assertContains('Page Two', $html);
     // Search for "Page One".
     $this->submitForm(['title' => 'Page One'], t('Filter'));
     $this->waitForAjaxToFinish();
     // Verify that only the "Page One" Node is present.
     $html = $session->getPage()->getHtml();
     $this->assertContains('Page One', $html);
     $this->assertNotContains('Page Two', $html);
     // Search for "Page Two".
     $this->submitForm(['title' => 'Page Two'], t('Filter'));
     $this->waitForAjaxToFinish();
     // Verify that only the "Page Two" Node is present.
     $html = $session->getPage()->getHtml();
     $this->assertContains('Page Two', $html);
     $this->assertNotContains('Page One', $html);
 }
Ejemplo n.º 15
0
  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {

    $custom_fields = \Drupal::configFactory()->listAll('ds.field.');

    foreach ($custom_fields as $config) {
      $field = \Drupal::config($config)->get();
      if ($field['type'] == $this->getType()) {
        foreach ($field['entities'] as $entity_type) {
          $key = $this->getKey($entity_type, $field);
          $this->derivatives[$key] = $base_plugin_definition;
          $this->derivatives[$key] += array(
            'title' => $field['label'],
            'properties' => $field['properties'],
            'entity_type' => $entity_type,
          );
          if (!empty($field['ui_limit'])) {
            $this->derivatives[$key]['ui_limit'] = explode("\n", $field['ui_limit']);
            // Ensure that all strings are trimmed, eg. don't have extra spaces,
            // \r chars etc.
            foreach ($this->derivatives[$key]['ui_limit'] as $k => $v) {
              $this->derivatives[$key]['ui_limit'][$k] = trim($v);
            }
          }
        }
      }
    }

    return $this->derivatives;
  }
 /**
  * Deletes config.
  *
  */
 protected function removeFilterConfig()
 {
     $mailchimp_campaign_filter = \Drupal::configFactory()->getEditable('filter.format.mailchimp_campaign');
     $mailchimp_campaign_filter->delete();
     // Clear cache.
     drupal_flush_all_caches();
 }
Ejemplo n.º 17
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     // Use a profile that contains required modules:
     $this->profile = $this->originalProfile;
     parent::setUp();
     \Drupal::configFactory()->addOverride(new ConfigOverrider());
 }
Ejemplo n.º 18
0
/**
 * Form submit handler for the theme settings form.
 */
function at_core_submit_layouts(&$form, &$form_state) {
  $build_info = $form_state->getBuildInfo();
  $values = $form_state->getValues();
  $theme = $build_info['args'][0];

  // Generate and save a new layout.
  if (isset($values['settings_layouts_enable']) && $values['settings_layouts_enable'] == 1) {

    $generateLayout = new LayoutSubmit($theme, $values);

    // Update the themes info file with new regions.
    $generateLayout->saveLayoutRegions();

    // Build and save the suggestions layout css files.
    $generateLayout->saveLayoutSuggestionsCSS();

    // Build and save the suggestions twig templates.
    $generateLayout->saveLayoutSuggestionsMarkup();

    // Add a new suggestion to the page suggestions array in config.
    if (!empty($values['ts_name'])) {
      $suggestion = trim($values['ts_name']);
      $clean_suggestion = str_replace('-', '_', $suggestion);
      $values["settings_suggestion_page__$clean_suggestion"] = $clean_suggestion;
    }

    // Delete suggestion files
    $templates_directory = drupal_get_path('theme', $theme) . '/templates/page';
    $css_directory = $values['settings_generated_files_path'];

    foreach ($values as $values_key => $values_value) {
      if (substr($values_key, 0, 18) === 'delete_suggestion_') {
        if ($values_value === 1) {
          $delete_suggestion_keys[] = Unicode::substr($values_key, 18);
        }
      }
    }

    if (isset($delete_suggestion_keys)) {
      foreach ($delete_suggestion_keys as $suggestion_to_remove) {
        $formatted_suggestion = str_replace('_', '-', $suggestion_to_remove);
        $template_file_path = $templates_directory . '/' . $formatted_suggestion . '.html.twig';
        $css_file_path = $css_directory . '/' . $theme . '--layout__' . $formatted_suggestion . '.css';
        if (file_exists($template_file_path)) {unlink($template_file_path);}
        if (file_exists($css_file_path)) {unlink($css_file_path);}
      }
    }
  }

  // Flush all caches. This is the only realy reliable way I have found to ensure
  // new templates and layouts work correctly.
  drupal_flush_all_caches();

  // Manage settings and configuration.
  // Must get mutable config otherwise bad things happen.
  $config = \Drupal::configFactory()->getEditable($theme . '.settings');
  $convertToConfig = new ThemeSettingsConfig();
  $convertToConfig->settingsConvertToConfig($values, $config);
}
Ejemplo n.º 19
0
 /**
  * Tests arguments in the preview form.
  */
 function testPreviewUI()
 {
     $this->drupalGet('admin/structure/views/view/test_preview/edit');
     $this->assertResponse(200);
     $this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
     $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
     $this->assertEqual(count($elements), 5);
     // Filter just the first result.
     $this->drupalPostForm(NULL, $edit = array('view_args' => '1'), t('Update preview'));
     $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
     $this->assertEqual(count($elements), 1);
     // Filter for no results.
     $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
     $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
     $this->assertEqual(count($elements), 0);
     // Test that area text and exposed filters are present and rendered.
     $this->assertFieldByName('id', NULL, 'ID exposed filter field found.');
     $this->assertText('Test header text', 'Rendered header text found');
     $this->assertText('Test footer text', 'Rendered footer text found.');
     $this->assertText('Test empty text', 'Rendered empty text found.');
     // Test feed preview.
     $view = array();
     $view['label'] = $this->randomMachineName(16);
     $view['id'] = strtolower($this->randomMachineName(16));
     $view['page[create]'] = 1;
     $view['page[title]'] = $this->randomMachineName(16);
     $view['page[path]'] = $this->randomMachineName(16);
     $view['page[feed]'] = 1;
     $view['page[feed_properties][path]'] = $this->randomMachineName(16);
     $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
     $this->clickLink(t('Feed'));
     $this->drupalPostForm(NULL, array(), t('Update preview'));
     $result = $this->xpath('//div[@id="views-live-preview"]/pre');
     $this->assertTrue(strpos($result[0], '<title>' . $view['page[title]'] . '</title>'), 'The Feed RSS preview was rendered.');
     // Test the non-default UI display options.
     // Statistics only, no query.
     $settings = \Drupal::configFactory()->getEditable('views.settings');
     $settings->set('ui.show.performance_statistics', TRUE)->save();
     $this->drupalGet('admin/structure/views/view/test_preview/edit');
     $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
     $this->assertText(t('Query build time'));
     $this->assertText(t('Query execute time'));
     $this->assertText(t('View render time'));
     $this->assertNoRaw('<strong>Query</strong>');
     // Statistics and query.
     $settings->set('ui.show.sql_query.enabled', TRUE)->save();
     $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
     $this->assertText(t('Query build time'));
     $this->assertText(t('Query execute time'));
     $this->assertText(t('View render time'));
     $this->assertRaw('<strong>Query</strong>');
     $this->assertText("SELECT views_test_data.name AS views_test_data_name\nFROM \n{views_test_data} views_test_data\nWHERE (( (views_test_data.id = &#039;100&#039; ) ))");
     // Test that the statistics and query are rendered above the preview.
     $this->assertTrue(strpos($this->getRawContent(), 'views-query-info') < strpos($this->getRawContent(), 'view-test-preview'), 'Statistics shown above the preview.');
     // Test that statistics and query rendered below the preview.
     $settings->set('ui.show.sql_query.where', 'below')->save();
     $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
     $this->assertTrue(strpos($this->getRawContent(), 'view-test-preview') < strpos($this->getRawContent(), 'views-query-info'), 'Statistics shown below the preview.');
 }
Ejemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->config = \Drupal::configFactory()->getEditable('sharethis.settings');
     // Create and log in admin user.
     $this->adminUser = $this->drupalCreateUser(['administer sharethis', 'administer nodes']);
     $this->drupalLogin($this->adminUser);
 }
 /**
  * Enables a theme.
  *
  * @param string $theme
  *   The theme.
  */
 public function enableTheme($theme)
 {
     // Enable the theme.
     \Drupal::service('theme_installer')->install([$theme]);
     $theme_config = \Drupal::configFactory()->getEditable('system.theme');
     $theme_config->set('default', $theme);
     $theme_config->save();
 }
Ejemplo n.º 22
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create a simple customer user account.
     $this->customer = $this->drupalCreateUser();
     // Ensure test mails are logged.
     \Drupal::configFactory()->getEditable('system.mail')->set('interface.uc_order', 'test_mail_collector')->save();
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Create user. Search content permission granted for the search block to
     // be shown.
     $this->drupalLogin($this->drupalCreateUser(['administer site configuration', 'access content']));
     $this->cronConfig = \Drupal::configFactory()->getEditable('examples.cron');
 }
Ejemplo n.º 24
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installSchema('system', 'key_value_expire');
     $this->storage = $this->container->get('entity_type.manager')->getStorage('search_api_index');
     // Set the default tracker since that's needed when creating a bare index.
     \Drupal::configFactory()->getEditable('search_api.settings')->set('default_tracker', 'default')->save();
 }
Ejemplo n.º 25
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->adminUser = $this->drupalCreateUser(array_keys($this->container->get('user.permissions')->getPermissions()));
     $this->drupalLogin($this->adminUser);
     $this->createContentType(['type' => 'page']);
     \Drupal::configFactory()->getEditable('image.settings')->set('suppress_itok_output', TRUE)->save();
 }
Ejemplo n.º 26
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $values = $form_state->getValues();
     $config = \Drupal::configFactory()->getEditable('custom.Eventbrite');
     $config->set('eventId', $values['eventid'])->save();
     $config->set('appKey', $values['appkey'])->save();
     $config->set('userKey', $values['userkey'])->save();
 }
Ejemplo n.º 27
0
  /**
   * {@inheritdoc}
   */
  protected function setup() {
    parent::setup();

    // Enable field templates
    \Drupal::configFactory()->getEditable('ds.settings')
      ->set('field_template', TRUE)
      ->save();
  }
Ejemplo n.º 28
0
 /**
  * Tests creation of RDF mapping.
  */
 function testMappingCreation()
 {
     $mapping_config_name = "{$this->prefix}.{$this->entityType}.{$this->bundle}";
     // Save bundle mapping config.
     rdf_get_mapping($this->entityType, $this->bundle)->save();
     // Test that config file was saved.
     $mapping_config = \Drupal::configFactory()->listAll('rdf.mapping.');
     $this->assertTrue(in_array($mapping_config_name, $mapping_config), 'Rdf mapping config saved.');
 }
Ejemplo n.º 29
0
 /**
  * {@inheritdoc}
  */
 public function blockSubmit($form, FormStateInterface $form_state)
 {
     $this->configuration['link_title'] = $form_state->getValue('link_title');
     $this->configuration['expanded'] = $form_state->getValue('expanded');
     $this->configuration['product_count'] = $form_state->getValue('product_count');
     // @todo Remove when catalog block theming is fully converted.
     $catalog_config = \Drupal::configFactory()->getEditable('uc_catalog.settings');
     $catalog_config->set('expand_categories', $form_state->getValue('expanded'))->set('block_nodecount', $form_state->getValue('product_count'))->save();
 }
Ejemplo n.º 30
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $config = \Drupal::configFactory()->getEditable('ng_lightbox.settings');
     $this->createContentType(['type' => 'page']);
     $node = $this->drupalCreateNode();
     $config->set('patterns', '/node/' . $node->id());
     $config->save();
 }