Ejemplo n.º 1
0
 /**
  * Testing that you can add a DAO directly to the cache without saving.
  *
  * @since 1.2.3
  */
 public function testAddToCache()
 {
     $config = ConfigProvider::getInstance();
     $oldSetting = $config->get('cache.provider.name');
     $config->set('cache.provider.name', 'Alpha\\Util\\Cache\\CacheProviderArray');
     $this->person->setOID('123');
     $this->person->addToCache();
     $fromCache = new Person();
     $fromCache->setOID($this->person->getOID());
     $this->assertTrue($fromCache->loadFromCache(), 'testing that the item loads from the cache');
     $this->assertEquals('unitTestUser', $fromCache->get('displayName', true), 'testing that you can add a DAO directly to the cache without saving');
     $config->set('cache.provider.name', $oldSetting);
 }
Ejemplo n.º 2
0
 /**
  * Testing the removeFromCache method.
  *
  * @since 1.2.1
  * @dataProvider getActiveRecordProviders
  */
 public function testRemoveFromCache($provider)
 {
     $config = ConfigProvider::getInstance();
     $config->set('db.provider.name', $provider);
     $config = ConfigProvider::getInstance();
     $oldSetting = $config->get('cache.provider.name');
     $config->set('cache.provider.name', 'Alpha\\Util\\Cache\\CacheProviderArray');
     $this->person->save();
     $fromCache = new Person();
     $fromCache->setOID($this->person->getOID());
     $this->assertTrue($fromCache->loadFromCache(), 'testing that the item loads from the cache');
     $fromCache->removeFromCache();
     $this->assertFalse($fromCache->loadFromCache(), 'testing that the item is gone from the cache');
     $config->set('cache.provider.name', $oldSetting);
 }