acquia_vwo-1.0.x-dev/tests/src/Functional/AcquiaVwoConfigTrait.php

tests/src/Functional/AcquiaVwoConfigTrait.php
<?php

namespace Drupal\Tests\acquia_vwo\Functional;

/**
 * Acquia VWO config trait.
 */
trait AcquiaVwoConfigTrait {

  /**
   * Acquia VWO settings.
   *
   * @var \Drupal\Core\Config\ImmutableConfig
   */
  protected $config;

  /**
   * Helper to initialize configuration.
   */
  public function setInitialConfig() {
    $this->config = \Drupal::configFactory()->getEditable('acquia_vwo.settings');
    $this->config->set('id', '123456')
      ->set('visibility.enabled', 'on')
      ->save();
  }

  /**
   * Helper to set field mapping.
   */
  public function setFieldMapping() {
    $mapping = [
      'content_section' => 'field_vwo_section',
      'content_keywords' => 'field_vwo_keywords',
      'persona' => 'field_vwo_persona',
    ];
    $config = \Drupal::configFactory()->getEditable('acquia_vwo.settings');
    $config->set('field_mapping', $mapping)->save();
  }

  /**
   * Helper to change user control settings.
   *
   * @param string $opt
   *   Opt in or out.
   */
  public function setUserControl($opt) {
    $this->config->set('visibility.user_control', $opt)->save();
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc