/** * @expectedException InvalidArgumentException */ public function testNonExistentViewThrowsException() { $finder = new IlluminateViewFinder($filesystem = m::mock('Illuminate\\Filesystem\\Filesystem'), array(__DIR__)); $finder->setThemeBag($bag = $this->getMockThemeBag()); $bag->shouldReceive('getCascadedPackageViewPaths')->with('foo')->once()->andReturn($paths = array('foo/1')); $filesystem->shouldReceive('exists')->with('foo/1/bar.blade.php')->once()->andReturn(false); $filesystem->shouldReceive('exists')->with('foo/1/bar.php')->once()->andReturn(false); $bag->shouldReceive('getActive')->once()->andReturn($active = m::mock('Cartalyst\\Themes\\ThemeInterface')); $active->shouldReceive('getSlug')->once()->andReturn('foo/bar'); $active->shouldReceive('getParentSlug')->once()->andReturn('foo/baz'); $bag->shouldReceive('getFallback')->once()->andReturn($fallback = m::mock('Cartalyst\\Themes\\ThemeInterface')); $fallback->shouldReceive('getSlug')->once()->andReturn('foo/corge'); $finder->find('foo::bar'); }
/** * Override the view finder used by Laravel to be our Theme view finder. * * @return void */ protected function overrideViewFinder() { $originalViewFinder = $this->app['view.finder']; $this->app['view.finder'] = $this->app->share(function ($app) use($originalViewFinder) { $paths = array_merge($app['config']['view.paths'], $originalViewFinder->getPaths()); $viewFinder = new IlluminateViewFinder($app['files'], $paths, $originalViewFinder->getExtensions()); $viewFinder->setThemeBag($app['themes']); foreach ($originalViewFinder->getPaths() as $location) { $viewFinder->addLocation($location); } foreach ($originalViewFinder->getHints() as $namespace => $hints) { $viewFinder->addNamespace($namespace, $hints); } return $viewFinder; }); // Now that we have overridden the "view.finder" IoC offest, we // need to re-register the factory as we cannot reset it // on the Factory at runtime, yet. $viewServiceProvider = new ViewServiceProvider($this->app); $viewServiceProvider->registerFactory(); }