Exemplo n.º 1
0
 /**
  * @depends testRedisSource
  */
 public function testCache()
 {
     $param = ['host' => '192.168.0.21'];
     $conf = new \Wwtg99\Config\Common\ConfigPool();
     $source = new \Wwtg99\Config\Source\RedisSource('config', $param);
     $conf->addSource($source);
     $conf->load();
     $this->assertEquals('v1', $conf->get('a'));
     $this->assertEquals('v2', $conf->get('d.d1'));
 }
Exemplo n.º 2
0
 public function testCache()
 {
     $cache = __DIR__ . DIRECTORY_SEPARATOR . 'test.cache';
     if (file_exists($cache)) {
         unlink($cache);
     }
     $conf = new \Wwtg99\Config\Common\ConfigPool($cache);
     $source = new \Wwtg99\Config\Source\FileSource(__DIR__, 'conf2.php');
     $source->addLoader(new \Wwtg99\Config\Source\Loader\PHPLoader());
     $conf->addSource($source);
     $conf->load();
     $this->assertEquals('val2', $conf->get('a'));
     $conf->set('a', 'aaa');
     $conf->saveCache();
     $conf = new \Wwtg99\Config\Common\ConfigPool($cache);
     $source = new \Wwtg99\Config\Source\FileSource(__DIR__, 'conf2.php');
     $source->addLoader(new \Wwtg99\Config\Source\Loader\PHPLoader());
     $conf->addSource($source);
     $conf->load();
     $this->assertEquals('aaa', $conf->get('a'));
 }