Commit 8d6b70c3 authored by Patrick Barroca's avatar Patrick Barroca 🐧

tests performances

parent 64c3cc0e
Pipeline #9349 passed with stage
in 41 minutes and 25 seconds
......@@ -23,10 +23,8 @@
class Class_AdminVarLoader extends Storm_Model_Loader {
use Trait_Translator;
/** @var array */
protected
$all_vars,
$_all_vars_values;
protected static $_all_vars_values, $_all_vars;
protected $_inited = false;
......@@ -115,10 +113,10 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
public function knownVars() {
if (null !== $this->all_vars)
return $this->all_vars;
if (null !== static::$_all_vars)
return static::$_all_vars;
return $this->all_vars =
return static::$_all_vars =
[
'avis' => $this->_getCommentVars(),
'modo' => $this->_getModerationVars(),
......@@ -537,15 +535,15 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
public function allVarsValues() {
if (null !== $this->_all_vars_values)
return $this->_all_vars_values;
if (null !== static::$_all_vars_values)
return static::$_all_vars_values;
$values=[];
foreach ($this->knownVars() as $key => $value) {
$values = array_merge($values, $value);
}
return $this->_all_vars_values = $values;
return static::$_all_vars_values = $values;
}
......@@ -584,8 +582,9 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
/** @category testing */
public function resetAllVars() {
$this->all_vars = null;
$this->_all_vars_values = null;
static::$_all_vars = null;
static::$_all_vars_values = null;
return $this;
}
......
......@@ -30,10 +30,33 @@ class Class_Journal_Type {
PREVIOUS_VALUE = 'previous_value',
NEW_VALUE = 'new_value';
protected static $_enabled = true;
protected $_journal;
/** @category testing */
public static function disable() {
static::$_enabled = false;
}
/** @category testing */
public static function enable() {
static::$_enabled = true;
}
/** @category testing */
protected static function _isEnabled() {
return static::$_enabled;
}
public static function save($model) {
if (!static::_isEnabled())
return;
$journal = Class_Journal::newInstance(['type' => static::MY_TYPE]);
if (!$journal->save())
return;
......
......@@ -126,6 +126,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe
$session = new Zend_Session_Namespace('FlashMessenger');
$session->unsetAll();
Class_Journal_Type::disable(); // perf: do not track adminvars by default
Class_AdminVar::beVolatile();
Class_TextReplacements::reset();
Class_AdminVar::set('CACHE_ACTIF', 0);
......
......@@ -69,6 +69,7 @@ abstract class ModelTestCase extends Storm_Test_ModelTestCase {
Class_Url::setBaseUrl('/bokeh');
Class_Url::setPhpMode('apache');
Class_Journal_Type::disable(); // perf: do not track adminvars by default
Class_AdminVar::beVolatile();
Class_AdminVar::set('CACHE_ACTIF', 0);
Class_AdminVar::set('BIBNUM', 1);
......
......@@ -20,10 +20,20 @@
*/
class JournalAdminVarPostTest extends Admin_AbstractControllerTestCase {
abstract class JournalAdminVarTestCase extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_Journal_Type::enable();
}
}
class JournalAdminVarPostTest extends JournalAdminVarTestCase {
public function setUp() {
parent::setUp();
Class_AdminVar::set('FACETTE_GENRE_LIBELLE', '');
......@@ -74,10 +84,7 @@ class JournalAdminVarPostTest extends Admin_AbstractControllerTestCase {
class JournalIndexActionTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
class JournalIndexActionTest extends JournalAdminVarTestCase {
public function setUp() {
parent::setUp();
......@@ -93,4 +100,4 @@ class JournalIndexActionTest extends Admin_AbstractControllerTestCase {
'La variable "FACETTE_GENRE_LIBELLE" a été modifiée de "" à "test" par "Harlock"',
$this->_response->getBody());
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment