Пример #1
0
 function testGetBool()
 {
     global $UBAR_GLOB;
     $path = $UBAR_GLOB['UBAR_ROOT'] . "test" . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "sample.properties";
     $pathToPropertiesClass = $UBAR_GLOB['UBAR_ROOT'] . "core" . DIRECTORY_SEPARATOR . "Properties.php";
     $props = new Properties($path);
     // test valid
     $this->assertEquals(TRUE, $props->getBool("sample.boolean"));
     // test unable to convert (other errors covered in test_get()
     try {
         $props->getBool("sample.badboolean");
         $this->fail("Expected exception trying to get property you can't convert to bool.");
     } catch (Exception $e) {
         $value = $props->get("sample.badboolean");
         $expectedMessage = "The property found, " . $value . ", with the key \"sample.badboolean\" could not be converted to a boolean value in the file \"{$path}\".";
         $this->assertEquals($expectedMessage, $e->getMessage());
     }
 }
Пример #2
0
    $props = new Properties($UBAR_GLOB['UBAR_CONFIG_OVERRIDE'], true);
} else {
    $props = new Properties($UBAR_GLOB['UBAR_ROOT'] . "ubar_config.properties", true);
}
# DEFINE CONSTANTS FROM PROPERTIES FILE
/**
 * Define DEV_MODE, defaulting to the value found in DEV_MODE if not set.
 * NOTE: This must be defined prior to other defines due to their values
 * switching on DEV_MODE
 *
 * NOTE: Some test classes may define this before init script loaded.
 *
 * @see GlobalConstants::DEV_MODE
 */
if (!isset($UBAR_GLOB['DEV_MODE'])) {
    $UBAR_GLOB['DEV_MODE'] = $props->getBool('DEV_MODE', GlobalConstants::DEV_MODE);
}
/**
 * Define a property appender based on dev mode to simplify the dev mode value
 * retrieval
 */
$UBAR_GLOB['PROP_APPEND'] = $UBAR_GLOB['DEV_MODE'] ? '_DEV_MODE' : '';
/**
 * Define the default locale.
 * @see GlobalConstants::LOCALE_DEFAULT
 */
$UBAR_GLOB['LOCALE_DEFAULT'] = $props->get('LOCALE_DEFAULT', GlobalConstants::LOCALE_DEFAULT);
/**
 * Define display errors flag.
 * @see GlobalConstants::DISPLAY_ERRORS
 */