Ejemplo n.º 1
0
 public function testLoadConfig()
 {
     $config = $this->config->get();
     $this->assertArrayHasKey('url', $config);
     $this->assertArrayHasKey('locale', $config);
     $this->assertArrayHasKey('os', $config);
     $this->assertArrayHasKey('child', $config);
     $this->assertTrue(is_array($config['child']));
 }
Ejemplo n.º 2
0
 public function testFileConfigOverlaysConfigFilesInOrderTheyAreLoaded()
 {
     $one = $this->_createConfig(array('red' => 'green', 'blue' => 'yellow'));
     $two = $this->_createConfig(array('red' => 'red'));
     $config = new FileConfig();
     $config->loadFile($one);
     $config->loadFile($two);
     $this->assertEquals($config->get('red'), 'red');
     $this->assertEquals($config->get('blue'), 'yellow');
 }
Ejemplo n.º 3
0
if (!function_exists("gettext")) {
    function gettext($str)
    {
        return $str;
    }
}
/**
 * Include the needed files
 */
require_once dirname(__FILE__) . '/lib/cli/Cli.php';
require_once dirname(__FILE__) . '/lib/config/FileConfig.php';
require_once dirname(__FILE__) . '/src/Generator.php';
// Try to read the config file if any
try {
    $config = new FileConfig(dirname(__FILE__) . '/conf/settings.conf');
    $locale = $config->get('language');
    $domain = 'messages';
    $lcDir = 'LC_MESSAGES';
    $path = 'conf/translations';
    $loc = substr($locale, 0, 5);
    $file = $path . '/' . $loc . '/' . $lcDir . '/' . $domain . '.mo';
    if (file_exists($file) == false) {
        throw new Exception('The selected language file (' . $file . ') does not exist!');
    }
    bindtextdomain($domain, $path);
    textdomain($domain);
    setlocale(LC_ALL, $locale);
} catch (Exception $e) {
    // This should be the no file exception, then use the default settings
}
// Start
Ejemplo n.º 4
0
 /**
  *
  */
 public function testGet()
 {
     $this->assertEquals('bar', $this->object->get('foo'));
     $this->setExpectedException('Exception');
     $this->object->get('woho');
 }