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' Blog:
Metatesting Testing Constructors
April 06, 2012 @ 08:28:00

In a new post to his blog Chris Hartjes, promoter of all things testing, looks a a method for testing constructors - an effective way to validate the things that happen when your objects are generated.

If you have a PHP application that makes heavy use of objects (which is probably 95% of you reading this) then you will have objects with constructor methods in them. It is also very likely that there is some stuff going on in those constructors. So how do you test things like this?

He includes a sample constructor that creates a container, pulls out some configuration values and reassigns them to class properties. He first tests that these properties have been set correctly by mocking out the object and overriding the configuration settings in the (dependency injection) container.

0 comments voice your opinion now!
testing constructors unittest mock object properties


blog comments powered by Disqus

Similar Posts

Jachim Coudenys: Using multiple databases in phpunit/dbunit with Composer

International PHP Magazine: Poll Question: Which is the Most Important Feature of PHP 5?

Jani Hartikainen's Blog: What is a null object, and when are they useful?

Patrick Allaert's Blog: Readable PHP code #2 - Make your API handle more!

Michelangelo van Dam's Blog: Quality Assurance on PHP projects - PHPUnit part 1


Community Events

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


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

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