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

Commit

Permalink
Hotfix: Use the provided database name of the resource
Browse files Browse the repository at this point in the history
Fixes #181
  • Loading branch information
michalbundyra committed Mar 24, 2019
1 parent 1b83f1c commit 742c91d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit 742c91d

Please sign in to comment.