[limb-svn] r6889 - in 3.x/trunk/limb/toolkit: src tests/cases
svn at limb-project.com
svn at limb-project.com
Wed Apr 2 01:03:05 MSD 2008
Author: pachanga
Date: 2008-04-02 01:03:04 +0400 (Wed, 02 Apr 2008)
New Revision: 6889
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6889
Modified:
3.x/trunk/limb/toolkit/src/lmbRegistry.class.php
3.x/trunk/limb/toolkit/src/lmbToolkit.class.php
3.x/trunk/limb/toolkit/tests/cases/lmbToolkitTest.class.php
Log:
-- reverting old behavior of not returning value of lmbRegistry :: restore()
Modified: 3.x/trunk/limb/toolkit/src/lmbRegistry.class.php
===================================================================
--- 3.x/trunk/limb/toolkit/src/lmbRegistry.class.php 2008-04-01 20:33:17 UTC (rev 6888)
+++ 3.x/trunk/limb/toolkit/src/lmbRegistry.class.php 2008-04-01 21:03:04 UTC (rev 6889)
@@ -19,7 +19,7 @@
*/
class lmbRegistry
{
- protected static $cache = array(array());
+ protected static $cache = array();
/**
* Adds a value to the registry
@@ -63,10 +63,7 @@
static function restore($name)
{
if(isset(self :: $cache[$name]))
- {
array_shift(self :: $cache[$name]);
- return self :: $cache[$name][0];
- }
else
throw new lmbException("No such registry entry '$name'");
}
Modified: 3.x/trunk/limb/toolkit/src/lmbToolkit.class.php
===================================================================
--- 3.x/trunk/limb/toolkit/src/lmbToolkit.class.php 2008-04-01 20:33:17 UTC (rev 6888)
+++ 3.x/trunk/limb/toolkit/src/lmbToolkit.class.php 2008-04-01 21:03:04 UTC (rev 6889)
@@ -58,21 +58,6 @@
protected $_signatures_loaded = false;
/**
- * Sets new tools object and clear signatures cache
- * @param lmbToolkitTools
- */
- protected function setTools($tools)
- {
- if(!is_array($tools))
- $this->_tools = array($tools);
- else
- $this->_tools = $tools;
-
- $this->_tools_signatures = array();
- $this->_signatures_loaded = false;
- }
-
- /**
* Follows Singleton pattern interface
* Returns toolkit instance. Takes instance from {@link lmbRegistry)
* If instance is not initialized yet - creates one with empty tools
@@ -89,6 +74,21 @@
}
/**
+ * Sets new tools object and clear signatures cache
+ * @param lmbToolkitTools
+ */
+ protected function setTools($tools)
+ {
+ if(!is_array($tools))
+ $this->_tools = array($tools);
+ else
+ $this->_tools = $tools;
+
+ $this->_tools_signatures = array();
+ $this->_signatures_loaded = false;
+ }
+
+ /**
* Fills toolkit instance with suggested tools and registers this tools in {@ling lmbRegisty}
* @see lmbRegistry
* @return lmbToolkit The only instance of lmbToolkit class
@@ -121,7 +121,6 @@
lmbRegistry :: set('__props', $toolkit->export());
lmbRegistry :: save('__props');
- //do we need to clone properties as well?
return $toolkit;
}
@@ -134,13 +133,20 @@
{
$toolkit = lmbToolkit :: instance();
- $tools = lmbRegistry :: restore('__tools');
- $props = lmbRegistry :: restore('__props');
+ lmbRegistry :: restore('__tools');
+ $tools = lmbRegistry :: get('__tools');
+ lmbRegistry :: restore('__props');
+ $props = lmbRegistry :: get('__props');
- $toolkit->reset();
- $toolkit->import($props);
- $toolkit->setTools($tools);
+ if($props !== null)
+ {
+ $toolkit->reset();
+ $toolkit->import($props);
+ }
+ if($tools !== null)
+ $toolkit->setTools($tools);
+
return $toolkit;
}
Modified: 3.x/trunk/limb/toolkit/tests/cases/lmbToolkitTest.class.php
===================================================================
--- 3.x/trunk/limb/toolkit/tests/cases/lmbToolkitTest.class.php 2008-04-01 20:33:17 UTC (rev 6888)
+++ 3.x/trunk/limb/toolkit/tests/cases/lmbToolkitTest.class.php 2008-04-01 21:03:04 UTC (rev 6889)
@@ -61,6 +61,16 @@
class lmbToolkitTest extends UnitTestCase
{
+ function setUp()
+ {
+ lmbToolkit :: save();
+ }
+
+ function tearDown()
+ {
+ lmbToolkit :: restore();
+ }
+
function testInstance()
{
$this->assertIdentical(lmbToolkit :: instance(), lmbToolkit :: instance());
@@ -118,6 +128,7 @@
$toolkit = lmbToolkit :: restore();
$this->assertEqual($toolkit->getFooCounter(), 2);
+ lmbToolkit :: restore();
}
function testSaveAndRestoreAlwaysReturnTheSameToolkitInstance()
More information about the limb-svn
mailing list