News Feed
Sections




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

Chris Hartjes:
Data Providers and Arrays
October 28, 2013 @ 11:49:36

Chris Hartjes, testing guru, has a post talking about using arrays in data providers for your unit tests. More specifically about some odd behavior one developer was seeing in their tests.

I was asked a question on Twitter by Tex Morgan about a problem he was having with PHPUnit data providers. He was trying to pass in some data and kept wondering why PHPUnit was serializing the data instead of doing what he was expecting.

The issue (example code included) was in how the data providers are expecting the data to be returned. His test was expecting an array but the data provider was returning things incorrectly. As Chris points out, the provider should return an array of arrays. The fix is easy, but could be confusing to someone not used to this slightly unusual return format.

0 comments voice your opinion now!
data provider unittest array return value example

Link: http://www.littlehart.net/atthekeyboard/2013/10/26/data-providers-and-arrays/

blog comments powered by Disqus

Similar Posts

Stijn Leenknegt's Blog: [PHP6] function-return-array idea!

Felix Geisendörfer's Blog: Containable 2.0 BETA

ParanoidFerret.com: Flex & PHP Tutorial - Transmitting data using JSON

Kevin Schroeder's Blog: ZendCon 2010 Podcast - Unit Testing in Zend Framework 1.8

Tim Koschuetzki's Blog: How to put Combined Fields Into CakePHP's Model->generateList()


Community Events

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


series version community interview release opinion framework voicesoftheelephpant api library laravel5 introduction php7 unittest video language development extension laravel podcast

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