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';