From 742c91dc9a69c4e8e7beb82c7ff97f86cabc9141 Mon Sep 17 00:00:00 2001 From: webimpress Date: Sun, 24 Mar 2019 22:34:22 +0000 Subject: [PATCH 1/4] Hotfix: Use the provided database name of the resource Fixes #181 --- src/Storage/Adapter/ExtMongoDbResourceManager.php | 2 +- .../Adapter/ExtMongoDbResourceManagerTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Storage/Adapter/ExtMongoDbResourceManager.php b/src/Storage/Adapter/ExtMongoDbResourceManager.php index f9f9b518b..e7faf7c10 100644 --- a/src/Storage/Adapter/ExtMongoDbResourceManager.php +++ b/src/Storage/Adapter/ExtMongoDbResourceManager.php @@ -98,7 +98,7 @@ public function getResource($id) } $collection = $resource['client_instance']->selectCollection( - isset($resouce['db']) ? $resource['db'] : 'zend', + isset($resource['db']) ? $resource['db'] : 'zend', isset($resource['collection']) ? $resource['collection'] : 'cache' ); $collection->createIndex(['key' => 1]); diff --git a/test/Storage/Adapter/ExtMongoDbResourceManagerTest.php b/test/Storage/Adapter/ExtMongoDbResourceManagerTest.php index ce02e50a4..225c68025 100644 --- a/test/Storage/Adapter/ExtMongoDbResourceManagerTest.php +++ b/test/Storage/Adapter/ExtMongoDbResourceManagerTest.php @@ -117,6 +117,20 @@ public function testGetResourceInitialized() $this->assertSame($resource, $this->object->getResource($id)); } + public function testCorrectDatabaseResourceName() + { + $id = 'foo'; + + $resource = [ + 'db' => getenv('TESTS_ZEND_CACHE_EXTMONGODB_DATABASE'), + 'server' => getenv('TESTS_ZEND_CACHE_EXTMONGODB_CONNECTSTRING'), + ]; + + $this->object->setResource($id, $resource); + + $this->assertSame($resource['db'], $this->object->getResource($id)->getDatabaseName()); + } + public function testGetResourceNewResource() { $id = 'foo'; From 60cac737c3510b747f108325f77b438c370498de Mon Sep 17 00:00:00 2001 From: webimpress Date: Wed, 28 Aug 2019 22:00:26 +0100 Subject: [PATCH 2/4] Adds CHANGELOG entry for #182 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 190d95121..2c16f5198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,10 @@ All notable changes to this project will be documented in this file, in reverse after creation. Wrong TTL was set instead of using default value from options. +- [#182](https://github.com/zendframework/zend-cache/pull/182) fixes + a typo in variable name within the `ExtMongoDbResourceManager::getResource` + method which prevented using custom db name when using that adapter. + ## 2.8.2 - 2018-05-01 ### Added From 3ff38aab1c23602eb83f48b29a3015bb5eb4ab74 Mon Sep 17 00:00:00 2001 From: webimpress Date: Wed, 28 Aug 2019 22:02:40 +0100 Subject: [PATCH 3/4] Update copyright year in modified files --- src/Storage/Adapter/ExtMongoDbResourceManager.php | 2 +- test/Storage/Adapter/ExtMongoDbResourceManagerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Storage/Adapter/ExtMongoDbResourceManager.php b/src/Storage/Adapter/ExtMongoDbResourceManager.php index e7faf7c10..a2cf4a5a6 100644 --- a/src/Storage/Adapter/ExtMongoDbResourceManager.php +++ b/src/Storage/Adapter/ExtMongoDbResourceManager.php @@ -1,7 +1,7 @@ Date: Wed, 28 Aug 2019 22:02:48 +0100 Subject: [PATCH 4/4] Remove unused import --- test/Storage/Adapter/ExtMongoDbResourceManagerTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Storage/Adapter/ExtMongoDbResourceManagerTest.php b/test/Storage/Adapter/ExtMongoDbResourceManagerTest.php index a85e69a7d..7f88c16e3 100644 --- a/test/Storage/Adapter/ExtMongoDbResourceManagerTest.php +++ b/test/Storage/Adapter/ExtMongoDbResourceManagerTest.php @@ -12,7 +12,6 @@ use PHPUnit\Framework\TestCase; use stdClass; use Zend\Cache\Exception; -use Zend\Cache\Storage\Adapter\ExtMongoDbOptions; use Zend\Cache\Storage\Adapter\ExtMongoDbResourceManager; /**