Example #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 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));
     }
 }