Skip to content
Permalink
Browse files

Improve support for testing non-default configurations

  • Loading branch information...
flack committed Jun 12, 2019
1 parent 0e4fbae commit 6724a16fe4ff8bc8398db31c19b69351b9bf91fc
Showing with 30 additions and 0 deletions.
  1. +12 −0 lib/midcom/baseclasses/components/configuration.php
  2. +18 −0 test/utilities/testcase.php
@@ -53,8 +53,20 @@ public static function set($component, $key, $value)
self::$_data[$component][$key] = $value;
}
/**
* Clear static cache
*
* @internal
*/
public static function reset()
{
self::$_data = [];
}
/**
* Initialize the global data storage
*
* @param string $component
*/
private static function _initialize($component)
{
@@ -81,6 +81,23 @@ public static function get_component_node($component)
return $topic;
}
/**
* Sets a config value for a component.
*
* This is useful e.g. in cases of form submissions, because the values set directly over the baseclass may
* get lost when the submit_dm helpers run the handler more than once
*
* @param string $component
* @param string $key
* @param mixed $value
*/
public function set_config($component, $key, $value)
{
$config = midcom_baseclasses_components_configuration::get($component, 'config');
$config->set($key, $value);
midcom_baseclasses_components_configuration::set($component, 'config', new midcom_helper_configuration($config->get_all()));
}
public function run_handler($topic, array $args = [])
{
if (is_object($topic)) {
@@ -413,6 +430,7 @@ public function tearDown()
$this->_testcase_objects = [];
org_openpsa_mail_backend_unittest::flush();
midcom_compat_environment::flush_registered_headers();
midcom_baseclasses_components_configuration::reset();
}
public static function TearDownAfterClass()

0 comments on commit 6724a16

Please sign in to comment.
You can’t perform that action at this time.