public function testRuleSets() { $digester = new Digester(); $digester->addRuleSet(new ConfigRuleSet('phruts-config')); $moduleConfig = new ModuleConfig(''); $digester->push($moduleConfig); $digester->parse(__DIR__ . '/../Resources/example-config.xml'); $this->assertTrue(count($moduleConfig->findActionConfigs()) > 0); $this->assertNotEmpty($moduleConfig->findActionConfig('/login')); }
public function setUp() { vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('cacheDir')); $application = new \Silex\Application(); $application[\Phruts\Util\Globals::DIGESTER] = $application->share(function () { $digester = new Digester(); $digester->addRuleSet(new ConfigRuleSet('phruts-config')); return $digester; }); $this->fileCache = new FileCacheModuleProvider($application); $this->fileCache->setCachePath(vfsStream::url('cacheDir')); }
/** * Registers services on the given app. * * This method should only be used to configure services and parameters. * It should not get services. * * @param \Silex\Application $app An Application instance */ public function register(\Silex\Application $app) { // Register our action server $app[\Phruts\Util\Globals::ACTION_KERNEL] = $app->share(function () use($app) { return new \Phruts\Action\ActionKernel($app); }); // Register our digester for when we need it $app[\Phruts\Util\Globals::DIGESTER] = $app->share(function () use($app) { $digester = new Digester(); $digester->addRuleSet(new ConfigRuleSet('phruts-config')); return $digester; }); $app[\Phruts\Util\Globals::MODULE_CONFIG_PROVIDER] = $app->share(function () use($app) { $provider = new FileCacheModuleProvider($app); // Set the cache $cache = $app[\Phruts\Util\Globals::CACHE_DIR]; if (empty($cache)) { $cache = getcwd() . '/../app/cache/'; } $provider->setCachePath($cache); return $provider; }); }