public function setUp() { $this->moduleConfig = new \Phruts\Config\ModuleConfig('example'); $forwardConfig1 = new \Phruts\Config\ForwardConfig(); $forwardConfig1->setName('path1'); $this->moduleConfig->addForwardConfig($forwardConfig1); $this->actionMapping = new \Phruts\Action\ActionMapping(); $forwardConfig2 = new \Phruts\Config\ForwardConfig(); $forwardConfig2->setName('path2'); $this->actionMapping->addForwardConfig($forwardConfig2); $this->actionMapping->setModuleConfig($this->moduleConfig); }
public function testModuleConfig() { $config = new ModuleConfig('prefix2'); $this->assertEquals('prefix2', $config->getPrefix()); $config->setPrefix('prefix'); $this->assertEquals('prefix', $config->getPrefix()); $controllerConfig = new ControllerConfig(); $controllerConfig->setProcessorClass('\\Mock\\Proccessor'); $controllerConfig->setContentType('application/x-javascript'); $controllerConfig->setNocache('true'); $controllerConfig->setInputForward('true'); $controllerConfig->setLocale('true'); $expected = "\\Phruts\\Config\\ControllerConfig[processorClass='\\\\Mock\\\\Proccessor',contentType='application/x-javascript',nocache=true,inputForward=true,locale=true]"; $this->assertEquals($expected, (string) $controllerConfig); $config->setControllerConfig($controllerConfig); $this->assertNotEmpty($config->getControllerConfig()); $actionConfig1 = new ActionConfig(); $actionConfig1->setPath('action1'); $actionConfig1->setType('\\ForwardConfig'); $config->addActionConfig($actionConfig1); $actionConfig2 = new ActionConfig(); $actionConfig2->setPath('action2'); $actionConfig2->setType('\\ForwardConfig'); $config->addActionConfig($actionConfig2); $this->assertNotEmpty($config->findActionConfig('/action1')); $this->assertNotEmpty($config->findActionConfig('/action2')); $config->removeActionConfig($actionConfig2); $this->assertEmpty($config->findActionConfig('/action2')); $actionClass = '\\MyActionConfigClass'; $config->setActionClass($actionClass); $this->assertEquals('\\MyActionConfigClass', $config->getActionClass()); $formBeanConfig1 = new FormBeanConfig(); $formBeanConfig1->setName('myForm1'); $formBeanConfig1->setType('\\MyForm1'); $formBeanConfig2 = new FormBeanConfig(); $formBeanConfig2->setName('myForm2'); $formBeanConfig2->setType('\\MyForm2'); $config->addFormBeanConfig($formBeanConfig1); $config->addFormBeanConfig($formBeanConfig2); $this->assertEquals(2, count($config->findFormBeanConfigs())); $this->assertEquals($formBeanConfig1, $config->findFormBeanConfig('myForm1')); $this->assertEquals($formBeanConfig2, $config->findFormBeanConfig('myForm2')); $config->removeFormBeanConfig($formBeanConfig2); $this->assertEmpty($config->findFormBeanConfig('myForm2')); $forwardConfig1 = new ForwardConfig(); $forwardConfig1->setName('welcome'); $forwardConfig1->setPath('welcome.html.twig'); $forwardConfig2 = new ForwardConfig(); $forwardConfig2->setName('login'); $forwardConfig1->setPath('login.html.twig'); $config->addForwardConfig($forwardConfig1); $config->addForwardConfig($forwardConfig2); $this->assertEquals($forwardConfig1, $config->findForwardConfig('welcome')); $this->assertEquals($forwardConfig2, $config->findForwardConfig('login')); $config->removeForwardConfig($forwardConfig1); $this->assertEmpty($config->findForwardConfig('welcome')); $dataSourceConfig = new DataSourceConfig(); $dataSourceConfig->setKey('key1'); $config->addDataSourceConfig($dataSourceConfig); $dataSourceConfig2 = new DataSourceConfig(); $dataSourceConfig2->setKey('key2'); $config->addDataSourceConfig($dataSourceConfig2); $this->assertEquals(2, count($config->findDataSourceConfigs())); $this->assertEquals($dataSourceConfig, $config->findDataSourceConfig('key1')); $this->assertEquals($dataSourceConfig2, $config->findDataSourceConfig('key2')); $config->removeDataSourceConfig($dataSourceConfig); $this->assertEmpty($config->findDataSourceConfig('key1')); $messageConfig = new MessageResourcesConfig(); $messageConfig->setKey('key1'); $config->addMessageResourcesConfig($messageConfig); $this->assertEquals($messageConfig, $config->findMessageResourcesConfig('key1')); $this->assertEquals(1, count($config->findMessageResourcesConfigs())); $config->removeMessageResourcesConfig($messageConfig); $this->assertEmpty($config->findMessageResourcesConfig('key1')); $plugInConfig = new PlugInConfig(); $plugInConfig->setKey('test'); $plugInConfig->setClassName('\\stdClass'); $config->addPlugInConfig($plugInConfig); $this->assertEquals(1, count($config->findPlugInConfigs())); $exceptionConfig = new ExceptionConfig(); $exceptionConfig->setType('\\Exception'); $config->addExceptionConfig($exceptionConfig); $this->assertEquals(1, count($config->findExceptionConfigs())); $this->assertEquals($exceptionConfig, $config->findExceptionConfig('\\Exception')); $config->removeExceptionConfig($exceptionConfig); $this->assertEmpty($config->findExceptionConfig('\\Exception')); // Test exception $config->freeze(); $this->assertTrue($config->getConfigured()); $this->setExpectedException('\\Phruts\\Exception\\IllegalStateException'); $config->setPrefix('prefix2'); }