Example #1
0
 /**
  * Load the config file reader to initiate the Permissions object
  *
  * @var $dir string Which folder your permissions are stored in
  */
 public function __construct($dir)
 {
     $this->_list = new Config();
     $this->_list->attach(new Config_File($dir));
 }
Example #2
0
 /**
  * If we've already loaded a config group then the correct variable
  * should be returned if we use the dot path notation to to request 
  * a var
  *
  * @test
  * @covers Config::load
  */
 public function test_load_can_get_var_from_dot_path_for_loaded_group()
 {
     $config = new Config();
     $reader = $this->getMock('Kohana_Config_Reader', array('load'));
     $reader->expects($this->once())->method('load')->with('beer')->will($this->returnValue(array('stout' => 'Guinness')));
     $config->attach($reader);
     $config->load('beer');
     $this->assertSame('Guinness', $config->load('beer.stout'));
 }
Example #3
0
 /**
  * Calling load() with a group that doesn't exist, should get it to use the last reader
  * to create a new config group
  *
  * @test
  * @covers Config::load
  */
 public function test_load_returns_new_config_group_if_one_dnx()
 {
     $config = new Config();
     $group = 'my_group';
     $reader1 = $this->getMock('Config_Reader');
     $reader2 = $this->getMock('Config_Reader', array('load'), array(), 'Config_Waffles');
     // This is a slightly hacky way of doing it, but it works
     $reader2->expects($this->exactly(2))->method('load')->with($group)->will($this->onConsecutiveCalls($this->returnValue(FALSE), $this->returnValue(clone $reader2)));
     $config->attach($reader1)->attach($reader2);
     $new_config = $config->load('my_group');
     $this->assertInstanceOf('Config_Waffles', $new_config);
     // Slightly taboo, testing a different api!!
     $this->assertSame(array(), $new_config->as_array());
 }