News Feed
Sections




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

Michelangelo van Dam:
Learning lessons at ZendUncon
November 13, 2012 @ 10:04:55

Michelangelo van Dam has shared something new he learned at the recent ZendCon conference about using fixtures with his PHPUnit testing.

In my previous post I already mentioned Sebastian Jerzy Wilczyński (@dj_sebastian_w) and his uncon session "Unit Testing for Databases using fixtures and phpunit". It made me wonder how much difference it would make if you use fixtures instead of testing database interactions using predefined sets of data. Since I work a lot with Zend Framework I was looking at how I could use fixtures and mock objects to follow Sebastian's guidelines. So I gave it a try. This is what I came up with.

He illustrates with some example code - a set of database data (the fixtures) and sample tests that use the Zend Framework's mapper and table gateway functionality to work with the tables. His test then mocks out the DbTable class for the "Order" object and forces a return of the database fixture data.

0 comments voice your opinion now!
phpunit database fixture mock zendframework unittest


blog comments powered by Disqus

Similar Posts

Till Klampaeckel's Blog: Iterating over a table (with Zend_Db_Table and Zend_Paginator)

Windows Skills Blog: Using SQLite as a database backend for a lightweight server

DevShed: Working with MySQL and Sessions to Serialize Objects in PHP (Part 3)

Community News: Free Adobe Webinar - Zend Framework and Flex/AIR (Zend_Amf)

Zend Developer Zone: Zend Framework Traveling Roadshow Coming to SF PHP Meetup


Community Events

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


opinion conference framework api laravel example php7 library introduction symfony2 performance series podcast application language interview install configure release community

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