<?php

require __DIR__ . '/../vendor/autoload.php';
use FUnit as fu;
fu::test("Test config_merge with two files", function () {
    $config = \Knlv\config_merge(__DIR__ . '/data', array('global', 'local'));
    $expected = (include __DIR__ . '/data/config_out1.php');
    fu::equal($config, $expected);
});
fu::test("Test config_merge with three files", function () {
    $config = \Knlv\config_merge(__DIR__ . '/data', array('global', 'local', 'development'));
    $expected = (include __DIR__ . '/data/config_out2.php');
    fu::equal($config, $expected);
});
Exemple #2
0
        return false;
    }
    unset($path);
}
$autoloader = (require 'vendor/autoload.php');
$appConfig = (include 'config/app.config.php');
if (is_readable('config/dev.config.php')) {
    $devConfig = (include 'config/dev.config.php');
    $appConfig['modules'] = array_unique(array_merge($appConfig['modules'], $devConfig['modules']));
    $appConfig['cache_config'] = isset($devConfig['cache_config']) ? $devConfig['cache_config'] : $appConfig['cache_config'];
}
$settings = [];
if ($appConfig['cache_config'] && is_readable($appConfig['cache_config'])) {
    $settings = (include $appConfig['cache_config']);
} else {
    $settings = Knlv\config_merge('config/settings', ['global', 'local'], $settings);
    if ($appConfig['cache_config'] && is_writable(dirname($appConfig['cache_config']))) {
        file_put_contents($appConfig['cache_config'], '<?php return ' . var_export($settings, true) . ';');
    }
}
$app = new Slim\App(['settings' => $settings]);
$container = $app->getContainer();
$container['autoloader'] = $autoloader;
$container['events'] = function ($c) {
    return 'Knlv\\events';
};
array_walk($appConfig['modules'], function ($module) use($app) {
    if (is_readable($module)) {
        call_user_func(include $module, $app);
    }
});