コード例 #1
0
 private function getApplication(array $paths = array(), array $hints = array())
 {
     $app = new Application();
     $app['env'] = 'testing';
     $app->instance('path', __DIR__ . '/../fixtures/Console/');
     // Storage path
     $app['path.storage'] = __DIR__;
     // Finder
     $finder = new FileViewFinder(new Filesystem(), $paths);
     if (count($hints) > 0) {
         foreach ($hints as $namespace => $namespace_paths) {
             $finder->addNamespace($namespace, $namespace_paths);
             $paths = array_merge($paths, $namespace_paths);
         }
     }
     // Total number of files across all paths
     $file_finder = new Finder();
     $file_finder->files()->in($paths)->name('*.twig');
     // View
     $view = m::mock('Illuminate\\View\\Environment');
     $view->shouldReceive('addExtension');
     $view->shouldReceive('getFinder')->andReturn($finder);
     $engine = m::mock('Illuminate\\View\\View');
     $engine->shouldReceive('render');
     $view->shouldReceive('make')->andReturn($engine);
     $app['view'] = $view;
     // Config
     $config = m::mock('Illuminate\\Container\\Container');
     $config->shouldReceive('get')->andReturnUsing(function ($x) {
         $args = func_get_args();
         if ($args[0] == 'twigbridge::extension') {
             return 'twig';
         }
         return array_pop($args);
     });
     $app['config'] = $config;
     return $app;
 }
コード例 #2
0
 /**
  * Creates a new FileViewFinder, copying the current contents
  *
  * @param FileViewFinder $finder
  * @param array          $paths
  *
  * @return FileViewFinder
  */
 protected function createViewFinder(FileViewFinder $finder, array $paths = [])
 {
     $new = new FileViewFinder(app('files'), $paths, $finder->getExtensions());
     foreach ($finder->getHints() as $namespace => $hints) {
         $new->addNamespace($namespace, $hints);
     }
     return $new;
 }