Permalink
Browse files

added StringUtils::resetRegisteredWrappers() for testing purposes

  • Loading branch information...
1 parent b394227 commit 5ef114bbd69b291435a7de34399fbc29c65125ee @marc-mabe committed Jan 6, 2013
Showing with 12 additions and 17 deletions.
  1. +11 −1 library/Zend/Stdlib/StringUtils.php
  2. +1 −16 tests/ZendTest/Stdlib/StringUtilsTest.php
View
12 library/Zend/Stdlib/StringUtils.php
@@ -29,7 +29,7 @@
*
* @var StringWrapperInterface[]
*/
- protected static $wrapperRegistry;
+ protected static $wrapperRegistry = null;
/**
* A list of known single-byte character encodings (upper-case)
@@ -102,6 +102,16 @@ public static function unregisterWrapper($wrapper)
}
/**
+ * Reset all registered wrappers so the default wrappers will be used
+ *
+ * @return void
+ */
+ public static function resetRegisteredWrappers()
+ {
+ static::$wrapperRegistry = null;
+ }
+
+ /**
* Get the first string wrapper supporting the given character encoding
* and supports to convert into the given convert encoding.
*
View
17 tests/ZendTest/Stdlib/StringUtilsTest.php
@@ -15,24 +15,9 @@
class StringUtilsTest extends TestCase
{
-
- protected $bufferedWrappers;
-
- public function setUp()
- {
- $this->bufferedWrappers = StringUtils::getRegisteredWrappers();
- }
-
public function tearDown()
{
- // reset registered wrappers
- foreach (StringUtils::getRegisteredWrappers() as $wrapper) {
- StringUtils::unregisterWrapper($wrapper);
- }
- foreach ($this->bufferedWrappers as $wrapper) {
- StringUtils::registerWrapper($wrapper);
- }
-
+ StringUtils::resetRegisteredWrappers();
}
public function getSingleByEncodings()

0 comments on commit 5ef114b

Please sign in to comment.