Skip to content

Commit

Permalink
Fixed exception is thrown on `yii\mongodb\rbac\MongoDbManager::invali…
Browse files Browse the repository at this point in the history
…dateCache()` invocation
  • Loading branch information
klimov-paul committed Feb 20, 2017
1 parent 2e55c6d commit 87dd407
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Yii Framework 2 mongodb extension Change Log
2.1.4 under development
-----------------------

- no changes in this release.
- Bug #187: Fixed exception is thrown on `yii\mongodb\rbac\MongoDbManager::invalidateCache()` invocation (jafaripur)


2.1.3 February 15, 2017
Expand Down
1 change: 0 additions & 1 deletion rbac/MongoDbManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,6 @@ public function invalidateCache()
$this->cache->delete($this->cacheKey);
$this->items = null;
$this->rules = null;
$this->parents = null;
}
}

Expand Down
14 changes: 14 additions & 0 deletions tests/rbac/MongoDbManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace yiiunit\extensions\mongodb\rbac;

use Yii;
use yii\caching\ArrayCache;
use yii\rbac\Item;
use yii\rbac\Permission;
use yii\rbac\Role;
Expand Down Expand Up @@ -507,4 +508,17 @@ public function testAssignRule()
$auth->update('Reader', $role);
$this->assertTrue($auth->checkAccess($userId, 'AdminPost', ['action' => 'print']));
}

public function testInvalidateCache()
{
$auth = $this->auth;
$auth->cache = new ArrayCache();
$this->prepareData();

$auth->loadFromCache();
$auth->getRule('reader');
$auth->invalidateCache();

$this->assertFalse($auth->cache->exists($auth->cacheKey));
}
}

0 comments on commit 87dd407

Please sign in to comment.