Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Hotfix: Use the provided database name of the resource #182

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Storage/Adapter/ExtMongoDbResourceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
14 changes: 14 additions & 0 deletions test/Storage/Adapter/ExtMongoDbResourceManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down