Example #1
0
 public function setUp()
 {
     $application = new \Silex\Application();
     $application[Globals::PREFIXES_KEY] = array();
     $application[Globals::MODULE_KEY] = new ModuleConfig('');
     $actionKernel = new ActionKernel($application);
     $this->action = new \Phruts\Actions\SwitchAction();
     $this->action->setActionKernel($actionKernel);
     $this->mapping = new ActionMapping();
     $this->request = Request::createFromGlobals();
     $this->response = new Response();
 }
Example #2
0
 public function testGetResources()
 {
     $getDataSource = self::getMethod('getResources');
     // Get from the request
     $messages = new \Phruts\Util\PropertyMessageResources(__DIR__ . '/UtilTest/Example');
     $this->request->attributes->set(\Phruts\Util\Globals::MESSAGES_KEY, $messages);
     $result = $getDataSource->invokeArgs($this->action, array($this->request));
     $this->assertNotEmpty($result);
     // Get from the application
     $request = \Symfony\Component\HttpFoundation\Request::create('http://localhost/test', 'GET', array(), array(), array(), array('PATH_INFO' => '/test'));
     $application = new \Silex\Application();
     $application[\Phruts\Util\Globals::PREFIXES_KEY] = array();
     $moduleConfig = new \Phruts\Config\ModuleConfig('');
     $application[\Phruts\Util\Globals::MODULE_KEY] = $moduleConfig;
     \Phruts\Util\RequestUtils::selectModule($request, $application);
     $key = 'key';
     $application[$key] = $messages;
     $actionKernel = new \Phruts\Action\ActionKernel($application);
     $this->action->setActionKernel($actionKernel);
     $result = $getDataSource->invokeArgs($this->action, array($this->request, $key));
     $this->assertNotEmpty($result);
 }