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

Commit

Permalink
Merge branch 'hotfix/182' into develop
Browse files Browse the repository at this point in the history
Forward port #182
  • Loading branch information
michalbundyra committed Aug 28, 2019
2 parents 40f0b9c + b6ba249 commit aa3d373
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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
Expand Down
4 changes: 2 additions & 2 deletions src/Storage/Adapter/ExtMongoDbResourceManager.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @see https://github.com/zendframework/zend-cache for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
* @copyright Copyright (c) 2018-2019 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License
*/

Expand Down 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
17 changes: 15 additions & 2 deletions test/Storage/Adapter/ExtMongoDbResourceManagerTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @see https://github.com/zendframework/zend-cache for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
* @copyright Copyright (c) 2018-2019 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License
*/

Expand All @@ -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;

/**
Expand Down Expand Up @@ -117,6 +116,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 aa3d373

Please sign in to comment.