예제 #1
0
 /**
  * @group ZF-10725
  */
 public function testActionsWithLeadingCapitalLettersShouldNotInvokeTruncatedViewScripts()
 {
     $this->request->setModuleName('default')->setControllerName('Controller')->setActionName('Action');
     $controller = new Bar_IndexController($this->request, $this->response, array());
     $this->helper->setActionController($controller);
     $scriptName = $this->helper->getViewScript();
     $this->assertEquals('controller/action.phtml', $scriptName);
 }
 /**
  * @group ZF-10725
  * @dataProvider providerViewScriptNameDoesNotIncludeDisallowedCharacters
  */
 public function testViewScriptNameDoesNotIncludeDisallowedCharacters($actionName)
 {
     $this->request->setModuleName('default')->setControllerName('foo')->setActionName($actionName);
     $controller = new Bar_IndexController($this->request, $this->response, array());
     $this->helper->setActionController($controller);
     $scriptName = $this->helper->getViewScript();
     $this->assertEquals('foo/my-bar.phtml', $scriptName);
 }
 /**
  * @see ZF-2738
  */
 public function testStockInflectorWorksWithDottedRequestParts()
 {
     $this->request->setModuleName('foo')->setControllerName('car.bar')->setActionName('baz');
     $controller = new Bar_IndexController($this->request, $this->response, array());
     $this->helper->setActionController($controller);
     $viewScriptPaths = $this->helper->view->getAllPaths();
     $expectedPathRegex = '#modules/foo/views/scripts/$#';
     $this->assertRegExp($expectedPathRegex, $this->_normalizePath($viewScriptPaths['script'][0]));
     $this->assertEquals('car-bar/baz.phtml', $this->helper->getViewScript());
 }
예제 #4
0
 public function testPostDispatchDoesNothingOnRedirect()
 {
     $this->request->setModuleName('bar')->setControllerName('index')->setActionName('test')->setDispatched(true);
     $this->response->setHttpResponseCode(302);
     $controller = new Bar_IndexController($this->request, $this->response, array());
     $this->helper->setActionController($controller);
     $this->helper->postDispatch();
     $content = $this->response->getBody();
     $this->assertNotContains('Rendered index/test.phtml in bar module', $content);
     $this->assertTrue(empty($content));
 }
예제 #5
0
 public function testPredispatchWithTwigTemplateEngine()
 {
     $this->request->setModuleName('foo')->setControllerName('index')->setActionName('bar');
     $controller = new Foo_IndexController($this->request, $this->response, array());
     $this->helper->setActionController($controller);
     $view = new Ano_View();
     $engine = new Ano_View_Engine_PhpEngine($view);
     $view->addTemplateEngine('twig', $engine);
     $this->helper->setView($view);
     $this->helper->preDispatch();
     $this->assertSame($engine, $this->helper->view->getTemplateEngine());
 }
예제 #6
0
 public function testRenderNormalizationIsCorrect()
 {
     $this->request->setModuleName('default')->setControllerName('foo')->setActionName('myBar');
     $controller = new Bar_IndexController($this->request, $this->response, array());
     $this->helper->setActionController($controller);
     $scriptName = $this->helper->getViewScript();
     $this->assertEquals('foo/mybar.phtml', $scriptName);
     $this->request->setModuleName('default')->setControllerName('foo')->setActionName('baz__bat');
     $scriptName = $this->helper->getViewScript();
     $this->assertEquals('foo/baz-bat.phtml', $scriptName);
     $this->request->setModuleName('default')->setControllerName('Foo_Bar')->setActionName('bar__baz');
     $scriptName = $this->helper->getViewScript();
     $this->assertEquals('foo/bar/bar-baz.phtml', $scriptName);
 }
예제 #7
0
    /**
     * @issue ZF-2443
     */
    public function testStockInflectorWorksWithViewBaseSpec()
    {
        $this->request->setModuleName('bar')  // bar must exist so the ViewRendere doesnt throw an exception
                      ->setControllerName('index')
                      ->setActionName('admin');
        $controller = new Bar_IndexController($this->request, $this->response, array());
        $this->helper->setActionController($controller);
                      
        $this->helper->setView($view = new Zend_View());
        $this->helper->setViewBasePathSpec(':moduleDir/:module');
        $this->helper->initView();
        
        $viewScriptPaths = $view->getAllPaths(); 

        $this->assertRegExp('#modules/bar/bar/scripts/$#', $viewScriptPaths['script'][0]);
        $this->assertEquals($this->helper->getViewScript(), 'index/admin.phtml');
    }