News Feed
Sections




News Archive
feed this:

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

Phil Sturgeon:
Build API's That You Wont Hate Part 1 - Useful Database Seeding
November 11, 2013 @ 09:19:33

Phil Sturgeon has posted the first part of a series he calls "Build API's That You Won't Hate", a follow up to one of his previous posts about building good APIs in your application.

A little while back I produced an article called Building a Decent API which was mostly a tongue-in-cheek list of things that I'd come across in other APIs that pissed me off, or that I had done myself and used my super-power of hindsight combined with sarcasm to make a set of rules for you to live by when building APIs. The combination of cheek and naughty words made that "eat your greens" article go down a lot more smoothly, but it certainly lacked a little substance but I always wanted to turn that into a much more in depth of blog posts.

In this first part of the series he covers one main topic - generating "good" data for you to use in your development environment. As he points out, using production data in development databases dangerous for several reasons. He suggests the Faker library to do what's called "database seeding" and generating fake, but accurately formatted, data to use for testing. He includes some sample code showing how to use the PHP tool to generate as set of seed user data. He also shows how to create a DatabaseSeeder class for Laravel and integrate it with the tool.

0 comments voice your opinion now!
api development database seeding faker laravel

Link: http://philsturgeon.co.uk/blog/2013/11/build-apis-part-1-useful-database-seeding

PHPMaster.com:
Simplifying Test Data Generation with Faker
February 19, 2013 @ 12:09:02

In a new post to PHPMaster.com today, Rakhitha Nimesh takes a look at Faker, a tool that can be used to generate random test case data as a part of your workflow.

Testing is an iterative part of the development process that we carry out to ensure the quality of our code. A large portion of this entails writing test cases and testing each unit of our application using random test data. Actual data for our application comes in when we release it to production, but during the development process we need fake data similar to real data for testing purposes. The popular open source library Faker provides us with the ability to generate different data suitable for a wide range of scenarios.

Faker uses built-in data providers like "Person", "Company", "DateTime" and "UserAgent" to give you randomized output from the data sets you define. Code is included showing how to create the provider in your objects, extending the correct provider and making a request for a property. A real-world example is also included about testing an email marketing engine for address, title, name and content. There's also a little bit added at the end showing how you can increase the randomness of the results returned by "seeding" the Faker engine.

0 comments voice your opinion now!
test data generation faker library object provider tutorial



Community Events





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


series list interview framework introduction release code developer testing threedevsandamaybe experience community podcast symfony2 opinion install api laravel language unittest

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