コード例 #1
0
 public function testForgetAll()
 {
     if (PermissionsCache::supportsAndAllowsMemcache()) {
         $super = User::getByUsername('super');
         Yii::app()->user->userModel = $super;
         $account = new Account();
         $account->name = 'Ocean Inc2.';
         $this->assertTrue($account->save());
         $combinedPermissions = 5;
         // Set some GeneralCache, which should stay in cache after cleanup
         GeneralCache::cacheEntry('somethingForTesting', 34);
         $value = GeneralCache::getEntry('somethingForTesting');
         $this->assertEquals(34, $value);
         PermissionsCache::cacheCombinedPermissions($account, $super, $combinedPermissions);
         $combinedPermissionsFromCache = PermissionsCache::getCombinedPermissions($account, $super);
         $this->assertEquals($combinedPermissions, $combinedPermissionsFromCache);
         PermissionsCache::forgetAll();
         try {
             PermissionsCache::getCombinedPermissions($account, $super);
             $this->fail('NotFoundException exception is not thrown.');
         } catch (NotFoundException $e) {
             // Data from generalCache should still be in cache
             $value = GeneralCache::getEntry('somethingForTesting');
             $this->assertEquals(34, $value);
         }
     }
     // To-Do: Add test for forgetAll with $forgetDbLevelCache = true. It could be added to testForgetAll() function.
     // To-Do: Add test for forgetSecurableItem with $forgetDbLevelCache = true. . It could be added to testForgetSecurableItem() function.
 }