A simple way to create arrays for Drupal testing

So after not playing Company of Heroes…. I’m back on Drupal module development, in particular how to create tests as quickly as possible.

I found two things:

    You can print out php arrays, classes etc pretty easily by using the “var_export($array,TRUE)” function (thanks Stack overflow! stackoverflow.com/questions/6759864/how-to-create-an-array-from-var-dump-result )
    And when you get things like “stdClass::__set_state()” you can replace it with a cast to object, like “(object)”. Thanks Drupal forums… https://drupal.org/node/584672

Now there’s no excuse for not testing your code :-)!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s