public function testUsePackageDefaults() { $yml = <<<YML install: allow_room: false allow_global: true packages: - Venyii\\HipChatCommander\\Test\\Package\\Dummy1 - Venyii\\HipChatCommander\\Package\\HelloWorld rooms: - id: 7331 packages: - name: helloWorld cache_ns: old_value default: lounge-default defaults: helloWorld: lounge-default: cache_ns: new_value restrict: cmd: - name: crawl user: [23527, 15564939] YML; $this->testInstance = Config::loadYaml($yml); $room = $this->testInstance->getRoomById(7331); $this->assertSame('new_value', $room->getPackageByName('helloWorld')->getCacheNs()); }
/** * @param string|null $yml */ protected function createTestConfig($yml = null) { if (!$yml) { $yml = ''; if ($this->getPackageClass()) { $yml .= <<<YML packages: - Venyii\\HipChatCommander\\Package\\HelloWorld - Venyii\\HipChatCommander\\Test\\Package\\Dummy1 YML; } if ($this->getPackageClass() !== 'Venyii\\HipChatCommander\\Package\\HelloWorld') { $yml .= <<<YML - {$this->getPackageClass()} YML; } $yml .= <<<YML rooms: - id: 7331 packages: - name: helloWorld - name: dummy1 - name: {$this->getPackageName()} YML; } $rootDir = vfsStream::setup(); $config = vfsStream::newFile('config.yml'); $config->setContent($yml); $rootDir->addChild($config); $configFile = $config->url(); $this->app['hc.config'] = $this->app->share(function () use($configFile) { return Config::loadYaml(file_get_contents($configFile)); }); }
use Venyii\HipChatCommander\Api; use Venyii\HipChatCommander\Config\Config; use Venyii\HipChatCommander\Package; date_default_timezone_set('UTC'); $app = new Silex\Application(); $app['debug'] = true; $app['hc.root_dir'] = realpath(__DIR__ . '/..'); $app['hc.src_dir'] = $app['hc.root_dir'] . '/src'; $app['hc.cache_dir'] = $app['hc.root_dir'] . '/cache'; $app['hc.pkg_dir'] = $app['hc.root_dir'] . '/pkg'; $app['hc.config'] = $app->share(function () use($app) { $configFile = $app['hc.root_dir'] . '/config/config.yml'; if (!file_exists($configFile)) { throw new Exception('Missing config file!'); } return Config::loadYaml(file_get_contents($configFile)); }); $app['hc.method_builder'] = $app->share(function () { return new Package\MethodGenerator(); }); $app['hc.package_loader'] = $app->share(function () use($app) { return new Package\Loader($app['hc.config']->getEnabledPackages()); }); $app['hc.cache_factory'] = $app->protect(function ($namespace) use($app) { return new FilesystemCache($app['hc.cache_dir'] . '/' . $namespace); }); $app['hc.cache'] = $app->share(function () use($app) { return $app['hc.cache_factory']('__core__'); }); $app['hc.pkg_cache'] = $app->protect(function ($ns, $package = null) use($app) { $pkgDir = $package ? '/' . $package : null;