A simple way to create arrays for Drupal testing

30 Jul 2013 . posts . Comments
#Drupal 7 #Module development

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 :-)!


Me

Anthony is an Australian software engineer and mathematician. As a UTS MBT graduate, Anthony is the technology co-founder of a property and cycling-tech startup and enjoys teaching and learning coding with the Australian startup scene.