Assert view template used in Laravel 4
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
Some of the controllers in a project I work on return different view templates depending on certain requirements. For example, the search()
method returns View::make('posts.search')
if no input is provided, but View::make('posts.results')
if a query string parameter is passed for the purpose of testing. However, there is no built-in function for asserting which view template is rendered when writing your functional tests. Here is a handy function you can pop into your TestCase
class to allow you to ensure the correct view template is being rendered when you need.