Skip to content

Commit b937a83

Browse files
committed
Change to using an array for old scope data
1 parent bfa5970 commit b937a83

1 file changed

Lines changed: 15 additions & 34 deletions

File tree

  • app/code/community/EcomDev/PHPUnit/Model

app/code/community/EcomDev/PHPUnit/Model/App.php

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,16 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App
5959
const XML_PATH_CONTROLLER_RESPONSE = 'phpunit/suite/controller/response/class';
6060

6161
/**
62-
* Old configuration model to be returned back
63-
* after unit tests are finished
64-
*
65-
* @var Mage_Core_Model_Config
66-
*/
67-
protected static $_oldConfig = null;
68-
69-
/**
70-
* Old application model to be returned back
71-
* after unit tests are finished
72-
*
73-
* @var Mage_Core_Model_App
74-
*/
75-
protected static $_oldApplication = null;
76-
77-
/**
78-
* Old event collection to be returned back
79-
* after the unit tests are finished
80-
*
81-
* @var Varien_Event_Collection
82-
*/
83-
protected static $_oldEventCollection = null;
84-
85-
/**
86-
* List of singletons in original application
62+
* Old test scope data to be returned back after unit tests are finished
8763
*
8864
* @var array
8965
*/
90-
protected static $_oldRegistry = null;
66+
protected static $_oldTestScope = array(
67+
'app' => null,
68+
'config' => null,
69+
'events' => null,
70+
'registry' => null,
71+
);
9172

9273
/**
9374
* Configuration model class name for unit tests
@@ -143,10 +124,10 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App
143124
public static function applyTestScope()
144125
{
145126
// Save old environment variables
146-
self::$_oldApplication = EcomDev_Utils_Reflection::getRestrictedPropertyValue('Mage', '_app');
147-
self::$_oldConfig = EcomDev_Utils_Reflection::getRestrictedPropertyValue('Mage', '_config');
148-
self::$_oldEventCollection = EcomDev_Utils_Reflection::getRestrictedPropertyValue('Mage', '_events');
149-
self::$_oldRegistry = EcomDev_Utils_Reflection::getRestrictedPropertyValue('Mage', '_registry');
127+
self::$_oldTestScope['app'] = EcomDev_Utils_Reflection::getRestrictedPropertyValue('Mage', '_app');
128+
self::$_oldTestScope['config'] = EcomDev_Utils_Reflection::getRestrictedPropertyValue('Mage', '_config');
129+
self::$_oldTestScope['events'] = EcomDev_Utils_Reflection::getRestrictedPropertyValue('Mage', '_events');
130+
self::$_oldTestScope['registry'] = EcomDev_Utils_Reflection::getRestrictedPropertyValue('Mage', '_registry');
150131

151132

152133
// Setting environment variables for unit tests
@@ -435,10 +416,10 @@ protected function _initStores()
435416
public static function discardTestScope()
436417
{
437418
// Setting environment variables for unit tests
438-
EcomDev_Utils_Reflection::setRestrictedPropertyValue('Mage', '_app', self::$_oldApplication);
439-
EcomDev_Utils_Reflection::setRestrictedPropertyValue('Mage', '_config', self::$_oldConfig);
440-
EcomDev_Utils_Reflection::setRestrictedPropertyValue('Mage', '_events', self::$_oldEventCollection);
441-
EcomDev_Utils_Reflection::setRestrictedPropertyValue('Mage', '_registry', self::$_oldRegistry);
419+
EcomDev_Utils_Reflection::setRestrictedPropertyValue('Mage', '_app', self::$_oldTestScope['app']);
420+
EcomDev_Utils_Reflection::setRestrictedPropertyValue('Mage', '_config', self::$_oldTestScope['config']);
421+
EcomDev_Utils_Reflection::setRestrictedPropertyValue('Mage', '_events', self::$_oldTestScope['events']);
422+
EcomDev_Utils_Reflection::setRestrictedPropertyValue('Mage', '_registry', self::$_oldTestScope['registry']);
442423
}
443424

444425
/**

0 commit comments

Comments
 (0)