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 Like a Boss in Laravel Models
February 19, 2013 @ 13:42:04

NetTuts.com has a new tutorial in their series covering the use of the Laravel 4 framework. In this new post, though, they show how to ensure quality in your application by unit testing your models (the "M" in "MVC").

If you're hoping to learn why tests are beneficial, this is not the article for you. Over the course of this tutorial, I will assume that you already understand the advantages, and are hoping to learn how best to write and organize your tests in Laravel 4. Version 4 of Laravel offers serious improvements in relation to testing, when compared to its previous release. This is the first article of a series that will cover how to write tests for Laravel 4 applications. We'll begin the series by discussing model testing.

They show how to set up the environment - making it use an in-memory SQLite database, call the migration to initialize it and run a "createApplication" to bootstrap the app. They then include an example if tests written against a "Post" model that extends the Ardent class. It also uses the FactoryMuff package to create objects. Some example tests are included, checking things like object properties, "posted at" date formats and the "slug" of a page (in a Page model and its tests).

0 comments voice your opinion now!
unittest laravel4 application tutorial ardent factorymuff


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso: Combining Zend Framework2 and Symfony2 components with Composer to build PHP projects

Master Zend Framework: Creating Custom ZFTool Diagnostic Classes

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

Zend Developer Zone: 2 Beginners Guides I Wish I had when I Started with PHP

DevShed: Building the Index Page for a PHP Email Application


Community Events





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


community artisanfiles security conference interview laravel library version introduction tool voicesoftheelephpant list symfony series podcast opinion language framework composer release

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