Author: Derick Rethans
Date: 2007-01-19 12:54:22 +0100 (Fri, 19 Jan 2007)
New Revision: 4529

Log:
- Implemented issue #9965: Support for delayed initialization through
  ezcBaseInit.
- Added the ezcConfigurationManager::reset() method that returns the
  manager to its unintialized state.

Added:
   trunk/Configuration/tests/configuration_manager_delayed_init_test.php
   trunk/Configuration/tests/test_classes.php
Modified:
   trunk/Configuration/ChangeLog
   trunk/Configuration/src/configuration_manager.php
   trunk/Configuration/tests/configuration_manager_test.php
   trunk/Configuration/tests/suite.php

Modified: trunk/Configuration/ChangeLog
===================================================================
--- trunk/Configuration/ChangeLog       2007-01-19 11:00:27 UTC (rev 4528)
+++ trunk/Configuration/ChangeLog       2007-01-19 11:54:22 UTC (rev 4529)
@@ -1,3 +1,12 @@
+1.2beta1 - [RELEASEDATE]
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Implemented issue #9965: Support for delayed initialization through
+  ezcBaseInit.
+- Added the ezcConfigurationManager::reset() method that returns the 
+  manager to its unintialized state.
+
+
 1.1 - Monday 18 December 2006
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

Modified: trunk/Configuration/src/configuration_manager.php
===================================================================
--- trunk/Configuration/src/configuration_manager.php   2007-01-19 11:00:27 UTC 
(rev 4528)
+++ trunk/Configuration/src/configuration_manager.php   2007-01-19 11:54:22 UTC 
(rev 4529)
@@ -96,6 +96,7 @@
         if ( is_null( self::$instance ) )
         {
             self::$instance = new ezcConfigurationManager();
+            ezcBaseInit::fetchConfig( 'ezcInitConfigurationManager', 
self::$instance );
         }
         return self::$instance;
     }
@@ -147,6 +148,18 @@
     }
 
     /**
+     * Resets the manager to the uninitialized state.
+     *
+     * @return void
+     */
+    public function reset()
+    {
+        $this->readerClass = null;
+        $this->location = null;
+        $this->options = array();
+    }
+
+    /**
      * Fetches a reader for the configuration $name.
      *
      * This method checks whether the configuration name was previously

Added: trunk/Configuration/tests/configuration_manager_delayed_init_test.php
===================================================================
--- trunk/Configuration/tests/configuration_manager_delayed_init_test.php       
2007-01-19 11:00:27 UTC (rev 4528)
+++ trunk/Configuration/tests/configuration_manager_delayed_init_test.php       
2007-01-19 11:54:22 UTC (rev 4529)
@@ -0,0 +1,40 @@
+<?php
+/**
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ * @version //autogentag//
+ * @filesource
+ * @package Configuration
+ * @subpackage Tests
+ */
+
+require_once( "test_classes.php" );
+
+/**
+ * @package Configuration
+ * @subpackage Tests
+ */
+class ezcConfigurationManagerDelayedInitTest extends ezcTestCase
+{
+    private $dbg;
+
+    public function tearDown()
+    {
+        $cfg = ezcConfigurationManager::getInstance();
+        $cfg->reset();
+    }
+
+    public function testDelayedInit()
+    {
+        ezcBaseInit::setCallback( 'ezcInitConfigurationManager', 
'testDelayedInitConfigurationManager' );
+        $cfg = ezcConfigurationManager::getInstance();
+        $this->assertAttributeEquals( 'ezcConfigurationIniReader', 
'readerClass', $cfg );
+    }
+
+    public static function suite()
+    {
+        return new 
PHPUnit_Framework_TestSuite("ezcConfigurationManagerDelayedInitTest");
+    }
+}
+
+?>


Property changes on: 
trunk/Configuration/tests/configuration_manager_delayed_init_test.php
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/Configuration/tests/configuration_manager_test.php
===================================================================
--- trunk/Configuration/tests/configuration_manager_test.php    2007-01-19 
11:00:27 UTC (rev 4528)
+++ trunk/Configuration/tests/configuration_manager_test.php    2007-01-19 
11:54:22 UTC (rev 4529)
@@ -41,6 +41,17 @@
         $this->assertSame( array(), $this->getAttribute( $config, 'options' ) 
);
     }
 
+    public function testReset()
+    {
+        $config = ezcConfigurationManager::getInstance();
+        $config->init( 'ezcConfigurationIniReader', 'files', array() );
+        $config->reset();
+
+        $this->assertSame( null, $this->getAttribute( $config, 'readerClass' ) 
);
+        $this->assertSame( null, $this->getAttribute( $config, 'location' ) );
+        $this->assertSame( array(), $this->getAttribute( $config, 'options' ) 
);
+    }
+
     public function testInitClassWrongInterface()
     {
         $config = ezcConfigurationManager::getInstance();

Modified: trunk/Configuration/tests/suite.php
===================================================================
--- trunk/Configuration/tests/suite.php 2007-01-19 11:00:27 UTC (rev 4528)
+++ trunk/Configuration/tests/suite.php 2007-01-19 11:54:22 UTC (rev 4529)
@@ -11,6 +11,7 @@
 /**
  * Require the tests
  */
+require_once 'configuration_manager_delayed_init_test.php';
 require_once 'configuration_test.php';
 require_once 'configuration_manager_test.php';
 require_once 'configuration_ini_parser_test.php';
@@ -29,6 +30,7 @@
         parent::__construct();
         $this->setName("Configuration");
 
+        $this->addTest( ezcConfigurationManagerDelayedInitTest::suite() );
         $this->addTest( ezcConfigurationTest::suite() );
         $this->addTest( ezcConfigurationManagerTest::suite() );
         $this->addTest( ezcConfigurationIniReaderTest::suite() );

Added: trunk/Configuration/tests/test_classes.php
===================================================================
--- trunk/Configuration/tests/test_classes.php  2007-01-19 11:00:27 UTC (rev 
4528)
+++ trunk/Configuration/tests/test_classes.php  2007-01-19 11:54:22 UTC (rev 
4529)
@@ -0,0 +1,9 @@
+<?php
+class testDelayedInitConfigurationManager
+{
+    static function configureObject( $object )
+    {
+        $object->init( 'ezcConfigurationIniReader', 
'Configuration/tests/files', array() );
+    }
+}
+?>


Property changes on: trunk/Configuration/tests/test_classes.php
___________________________________________________________________
Name: svn:eol-style
   + native

-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to