Sfoglia il codice sorgente

Zend_Memory: backends naming processing improvement. ZF-9023.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20804 44c647ce-9c0f-0410-b52a-842ac1e357ba
alexander 16 anni fa
parent
commit
eda3df46c5
2 ha cambiato i file con 23 aggiunte e 3 eliminazioni
  1. 11 3
      library/Zend/Memory.php
  2. 12 0
      tests/Zend/Memory/MemoryManagerTest.php

+ 11 - 3
library/Zend/Memory.php

@@ -53,10 +53,18 @@ class Zend_Memory
             return new Zend_Memory_Manager();
             return new Zend_Memory_Manager();
         }
         }
 
 
-        // because lowercase will fail
-        $backend = @ucfirst(strtolower($backend));
+        // Look through available backendsand
+        // (that allows to specify it in any case)
+        $backendIsFound = false;
+        foreach (Zend_Cache::$availableBackends as $zendCacheBackend) {
+            if (strcasecmp($backend, $zendCacheBackend) == 0) {
+                $backend = $zendCacheBackend;
+                $backendIsFound = true;
+                break;
+            }
+        }
 
 
-        if (!in_array($backend, Zend_Cache::$availableBackends)) {
+        if (!$backendIsFound) {
             require_once 'Zend/Memory/Exception.php';
             require_once 'Zend/Memory/Exception.php';
             throw new Zend_Memory_Exception("Incorrect backend ($backend)");
             throw new Zend_Memory_Exception("Incorrect backend ($backend)");
         }
         }

+ 12 - 0
tests/Zend/Memory/MemoryManagerTest.php

@@ -90,6 +90,18 @@ class Zend_Memory_MemoryManagerTest extends PHPUnit_Framework_TestCase
 
 
 
 
     /**
     /**
+     * tests the Memory Manager backends naming processing
+     *
+     * @group ZF-9023
+     */
+    public function testBackendNamingProcessing()
+    {
+        /** 'File' backend */
+        $backendOptions = array('cache_dir' => $this->cacheDir); // Directory where to put the cache files
+        $memoryManager = Zend_Memory::factory('fIlE', $backendOptions);
+    }
+
+    /**
      * tests the Memory Manager settings
      * tests the Memory Manager settings
      */
      */
     public function testSettings()
     public function testSettings()