You are here

class TestingAppService in Forena Reports 8

Hierarchy

Expanded class hierarchy of TestingAppService

1 file declares its use of TestingAppService
FrxTestCase.php in tests/src/Unit/FrxTestCase.php

File

tests/src/Unit/Mock/TestingAppService.php, line 16

Namespace

Drupal\Tests\forena\Unit\Mock
View source
class TestingAppService extends AppService {
  public $language = 'en';
  public $default_language = 'en';
  public $data_directory = '/tmp';
  public $has_access = TRUE;

  // Data Pathways.
  public $reportDirectory;
  public $reportIncludes;
  public $siteContext;
  public $modulePath;
  public $currentPath = 'reports/test';

  /** @var  ParameterForm */
  public $parameterForm;
  public $form_state;

  /**
   * Return Current site context.
   * @return array
   */
  public function __construct() {
    $this->modulePath = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
    $path = $this->modulePath;
    $site = [];
    $site['base_path'] = '/';
    $site['dir'] = '';
    $site['base_url'] = 'http://example.com';
    $site['user_name'] = 'testuser';
    $site['uid'] = 1;
    $site['language'] = $this->language;
    $this->siteContext = $site;
    $this->default_skin = 'default';

    // Determine module installation path based on current code
    $this->reportDirectory = "{$path}/tests/reports_overriden";
    $this->reportIncludes = [
      "{$path}/tests/reports",
    ];
  }

  /*
   * Mock alter function.
   */
  public function alter($hook, &$var1, $var2 = NULL) {
  }

  /**
   * @return bool
   *   Fake out access check.
   */
  public function access($right) {
    return $this->has_access;
  }
  public function getRendererPlugins() {
    return [
      'FrxAjax' => '\\Drupalforena\\FrxPlugin\\Renderer\\FrxAjax',
      'FrxCrosstab' => '\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxCrosstab',
      'FrxInclude' => '\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxInclude',
      'FrxMyReports' => '\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxMyReports',
      'FrxMenu' => FrxMenu::class,
      'FrxParameterForm' => '\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxParameterForm',
      'FrxSource' => '\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxSource',
      'FrxSVGGraph' => '\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxSVGGraph',
      'FrxTemplate' => '\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxTemplate',
      'FrxTitle' => '\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxTitle',
      'FrxXML' => '\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxXML',
      'RendererBase' => '\\Drupal\\forena\\FrxPlugin\\Renderer\\RendererBase',
    ];
  }
  public function getAjaxPlugins() {
    return [
      'invoke' => '\\Drupal\\forena\\FrxPlugin\\AjaxCommand\\Invoke',
    ];
  }
  public function getContextPlugins() {
    return [
      'custom_security' => 'Drupal\\Tests\\forena\\Unit\\FrxPlugin\\Context\\CustomSecurity',
      'FrxReport' => 'Drupal\\forena\\FrxPlugin\\Context\\FrxReport',
    ];
  }
  public function getDocumentPlugins() {
    return [
      'csv' => '\\Drupal\\forena\\FrxPlugin\\Document\\CSV',
      'drupal' => '\\Drupal\\forena\\FrxPlugin\\Document\\Drupal',
      'doc' => '\\Drupal\\forena\\FrxPlugin\\Document\\Word',
      'email' => '\\Drupal\\forena\\FrxPlugin\\Document\\EmailMerge',
      'html' => '\\Drupal\\forena\\FrxPlugin\\Document\\HTML',
      'svg' => '\\Drupal\\forena\\FrxPlugin\\Document\\SVG',
      'xls' => '\\Drupal\\forena\\FrxPlugin\\Document\\Excel',
      'xml' => '\\Drupal\\forena\\FrxPlugin\\Document\\XML',
    ];
  }
  public function getDriverPlugins() {
    return [
      'FrxDrupal' => '\\Drupal\\forena\\FrxPlugin\\Driver\\FrxDrupal',
      'FrxFiles' => '\\Drupal\\forena\\FrxPlugin\\Driver\\FrxFiles',
      'FrxMSSQL' => '\\Drupal\\forena\\FrxPlugin\\Driver\\FrxMSSQl',
      'FrxOracle' => '\\Drupal\\forena\\FrxPlugin\\Driver\\FrxOracle',
      'FrxPDO' => '\\Drupal\\forena\\FrxPlugin\\Driver\\FrxPDO',
      'FrxPostgres' => '\\Drupal\\forena\\FrxPlugin\\Driver\\FrxPostgres',
    ];
  }

  /**
   * Return the forena provided formatter plugin.
   * @return array
   */
  public function getFormatterPlugins() {
    return [
      '\\Drupal\\forena\\FrxPlugin\\FieldFormatter\\Formatter',
    ];
  }
  public function buildParametersForm($parameters) {
    $controller = $this->parameterForm;
    $form = [];
    $form = $controller
      ->buildForm($form, $this->form_state, $parameters);
    return $form;
  }
  public function currentPath() {
    return $this->currentPath;
  }
  public function error($short_message = '', $log = '') {
    echo "{$short_message}\n";
    echo "{$log}\n";
  }
  public function debug($short_message = '', $log = '') {
    echo "{$short_message}\n";
    echo "{$log}\n";
  }
  public function dataDirectory() {
    return $this->data_directory;
  }
  public function drupalRender(&$elements) {
    return $elements;
  }

  // Override ReportLink because of URL services.
  public function reportLink($text, $field) {
    $field['href'] = $field['link'];
    unset($field['link']);
    $field = array_filter($field);
    $attributes = '';
    foreach ($field as $key => $attr) {
      $attributes .= "{$key}='{$attr}' ";
    }
    $attributes = trim($attributes);
    return "<a {$attributes}>{$text}</a>";
  }
  public function url($path, $options) {
    if (strpos($path, '/') !== 0 && strpos($path, 'http' == FALSE)) {
      $path = "/{$path}";
    }
    $url = $path;
    if (isset($options['query'])) {
      $query_string = '?';
      foreach ($options['query'] as $key => $value) {
        $query_string .= "{$key}={$value}&";
      }
      $query_string = rtrim($query_string, '&');
      $url .= $query_string;
    }
    return $url;
  }

  /**
   *
   * @param $menu_id
   * @param $max_depth
   * @return mixed
   */
  public function renderMenu($menu_id, $options = []) {
    return "<ul class='{$menu_id}'><li>Menu Item</li></ul>\n";
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AppService::$base_path public property
AppService::$default_skin public property
AppService::$doc_defaults public property
AppService::$doc_formats public property
AppService::$input_format public property
AppService::$instance protected static property
AppService::correctModulePath public function
AppService::findLibrary public function Use host application specificy to find the location of a library.
AppService::getForenaProviders public function
AppService::instance public static function Singleton Factory
TestingAppService::$currentPath public property
TestingAppService::$data_directory public property
TestingAppService::$default_language public property
TestingAppService::$form_state public property
TestingAppService::$has_access public property
TestingAppService::$language public property
TestingAppService::$modulePath public property
TestingAppService::$parameterForm public property @var ParameterForm
TestingAppService::$reportDirectory public property
TestingAppService::$reportIncludes public property
TestingAppService::$siteContext public property Overrides AppService::$siteContext
TestingAppService::access public function Overrides AppService::access
TestingAppService::alter public function Overrides AppService::alter
TestingAppService::buildParametersForm public function Overrides AppService::buildParametersForm
TestingAppService::currentPath public function Overrides AppService::currentPath
TestingAppService::dataDirectory public function Determine data directory. Overrides AppService::dataDirectory
TestingAppService::debug public function Debug handler Enter description here ... Overrides AppService::debug
TestingAppService::drupalRender public function Overrides AppService::drupalRender
TestingAppService::error public function General wrapper procedure for reporting erros Overrides AppService::error
TestingAppService::getAjaxPlugins public function Returns the list of ajax plugins. Overrides AppService::getAjaxPlugins
TestingAppService::getContextPlugins public function Returns the list of context plugins. Overrides AppService::getContextPlugins
TestingAppService::getDocumentPlugins public function Overrides AppService::getDocumentPlugins
TestingAppService::getDriverPlugins public function Overrides AppService::getDriverPlugins
TestingAppService::getFormatterPlugins public function Return the forena provided formatter plugin. Overrides AppService::getFormatterPlugins
TestingAppService::getRendererPlugins public function Returns the list of Renderer plugins Overrides AppService::getRendererPlugins
TestingAppService::renderMenu public function Overrides AppService::renderMenu
TestingAppService::reportLink public function Overrides AppService::reportLink
TestingAppService::url public function Overrides AppService::url
TestingAppService::__construct public function Return Current site context. Overrides AppService::__construct