Esempio n. 1
0
    /**
     * Tests (script|helper|filter) paths can be added, that they are added
     * in the proper order, and that directory separators are properly handled.
     *
     * @param string $pathType one of "script", "helper", or "filter".
     */
    protected function _testAddPath($pathType)
    {
        $view   = new Zend_View();
        $prefix = 'Zend_View_' . ucfirst($pathType) . '_';

        // introspect default paths and build expected results.
        $reflector     = $view->getAllPaths();
        $expectedPaths = $reflector[$pathType];

        if ('script' == $pathType) {
            array_unshift($expectedPaths, 'baz' . DIRECTORY_SEPARATOR);
            array_unshift($expectedPaths, 'bar' . DIRECTORY_SEPARATOR);
            array_unshift($expectedPaths, 'foo' . DIRECTORY_SEPARATOR);
        } else {
            array_unshift($expectedPaths, array('prefix' => $prefix, 'dir' => 'baz' . DIRECTORY_SEPARATOR));
            array_unshift($expectedPaths, array('prefix' => $prefix, 'dir' => 'bar' . DIRECTORY_SEPARATOR));
            array_unshift($expectedPaths, array('prefix' => $prefix, 'dir' => 'foo' . DIRECTORY_SEPARATOR));
        }

        // add paths
        $func = 'add' . ucfirst($pathType) . 'Path';
        $view->$func('baz');    // no separator
        $view->$func('bar\\');  // windows
        $view->$func('foo/');   // unix

        // introspect script paths after adding two new paths
        $reflector   = $view->getAllPaths();
        $actualPaths = $reflector[$pathType];

        $this->assertSame($expectedPaths, $actualPaths);
    }
Esempio n. 2
0
 /**
  * Tests (script|helper|filter) paths can be added, that they are added
  * in the proper order, and that directory separators are properly handled.
  *
  * @param string $pathType one of "script", "helper", or "filter".
  */
 protected function _testAddPath($pathType)
 {
     $view = new Zend_View();
     $prefix = 'Zend_View_' . ucfirst($pathType) . '_';
     // introspect default paths and build expected results.
     $reflector = $view->getAllPaths();
     $expectedPaths = $reflector[$pathType];
     if ($pathType != 'script') {
         $expectedPaths = $this->_filterPath($expectedPaths[$prefix]);
     }
     array_push($expectedPaths, 'baz');
     array_push($expectedPaths, 'bar');
     array_push($expectedPaths, 'foo');
     // add paths
     $func = 'add' . ucfirst($pathType) . 'Path';
     $view->{$func}('baz');
     // no separator
     $view->{$func}('bar\\');
     // windows
     $view->{$func}('foo/');
     // unix
     // introspect script paths after adding two new paths
     $reflector = $view->getAllPaths();
     $actualPaths = $this->_filterPath($reflector[$pathType]);
     switch ($pathType) {
         case 'script':
             $this->assertSame(array_reverse($expectedPaths), $actualPaths);
             break;
         case 'helper':
         case 'filter':
         default:
             $this->assertTrue(array_key_exists($prefix, $actualPaths));
             $this->assertSame($expectedPaths, $actualPaths[$prefix], 'Actual: ' . var_export($actualPaths, 1) . "\nExpected: " . var_export($expectedPaths, 1));
     }
 }
    /**
     * @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');
    }