News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

NetTuts.com:
Testing Laravel Controllers
April 24, 2013 @ 09:24:06

NetTuts.com has posted a new article for the Laravel users out there - a tutorial showing how to test Laravel controllers via PHPUnit tests.

Testing controllers isn't the easiest thing in the world. Well, let me rephrase that: testing them is a cinch; what's difficult, at least at first, is determining what to test. Should a controller test verify text on the page? Should it touch the database? Should it ensure that variables exist in the view? If this is your first hay-ride, these things can be confusing! Let me help.

They break up the testing process into three main chunks - isolation of the tests (mocking where need be), calling the controller method and running the checks (assertions) to be sure the result is valid. They start with a basic controller test that runs a GET request on the "posts" method. They also mention the assertion helper methods included with Laravel controller testing, things like "assertRedirectedTo" and "assertSessionHas". The article then gets into moreo practical examples showing a TDD approach to testing some simple controller calls, mocking data connections, handling redirects and repositories.

0 comments voice your opinion now!
laravel controller testing tutorial helper

Link: http://net.tutsplus.com/tutorials/php/testing-laravel-controllers

blog comments powered by Disqus

Similar Posts

DevShed: Introducing the Chain of Responsibility Between PHP Objects

Klaus Graefensteiner's Blog: Getting Wordpress installed in a jiffy on Windows 7 using the WPI

Zend Developer Zone: Data-centric Adobe Flash Builder development with the Zend Framework

Sebastian Bergmann's Blog: Distributed Testing with PHPUnit 3.1

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 12)


Community Events





Don't see your event here?
Let us know!


install configure unittest wordpress developer community podcast code library language release introduction application list series laravel threedevsandamaybe bugfix api interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework